All of lore.kernel.org
 help / color / mirror / Atom feed
* Squash & Merge Implementation
@ 2018-08-03 12:01 Vadim Belov
  2018-08-03 13:49 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: Vadim Belov @ 2018-08-03 12:01 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1161 bytes --]

Hello,
I'm trying to manually implement Github's *Squash&Merge *functionality.
After looking many forums like stackoverflow.com I'm still struggling with
the issue.

*The scenario is as follows*:
- master is a protected branch (configured on github)
- a service user *svc *is permitted to push to master (configured on github)
- other users don't have such permissions
- github PR status check is set to SUCCESS before execution of any set of
git commands below

1. This merges successfully without squash:
git checkout origin/master
git merge ${PR-Branch}
git push origin HEAD:master
git push origin --delete ${PR-Branch}

2. This closes the PR, but there is no update seen on master:
git checkout origin/master
git merge --squash --commit ${PR-Branch}
git push origin HEAD:master
git push origin --delete ${PR-Branch}

3. This fails to push to master with the error "GH006: Protected branch
update failed"  (despite that the PR is set to SUCCESS):
git checkout origin/master
git merge --squash ${PR-Branch}
git commit -am"comment"
git push origin HEAD:${m_mainBranch}
git push origin --delete ${m_prBranch}


Will appreciate your help on this.

Thanks,
Vadim

[-- Attachment #2: Type: text/html, Size: 2668 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Squash & Merge Implementation
  2018-08-03 12:01 Squash & Merge Implementation Vadim Belov
@ 2018-08-03 13:49 ` Jeff King
  2018-08-03 17:23   ` Vadim Belov
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2018-08-03 13:49 UTC (permalink / raw)
  To: Vadim Belov; +Cc: git

On Fri, Aug 03, 2018 at 03:01:15PM +0300, Vadim Belov wrote:

> 1. This merges successfully without squash:
> git checkout origin/master
> git merge ${PR-Branch}
> git push origin HEAD:master
> git push origin --delete ${PR-Branch}

Right, this is a normal merge.

> 2. This closes the PR, but there is no update seen on master:
> git checkout origin/master
> git merge --squash --commit ${PR-Branch}
> git push origin HEAD:master
> git push origin --delete ${PR-Branch}

Doing "merge --squash --commit" doesn't do what you expect; namely
"--commit" does not override the non-committing nature of "--squash". It
only override a "--no-commit" found elsewhere.

IMHO this is something that could be improved in Git (i.e., telling the
difference between "the user did not say --no-commit" and "the user said
--commit" and respecting it for --squash).

But that explains what you see. The push to master is a noop, since you
didn't make a new commit. And then deleting the PR branch on GitHub
auto-closes the PR.

> 3. This fails to push to master with the error "GH006: Protected branch
> update failed"  (despite that the PR is set to SUCCESS):
> git checkout origin/master
> git merge --squash ${PR-Branch}
> git commit -am"comment"
> git push origin HEAD:${m_mainBranch}
> git push origin --delete ${m_prBranch}

So here you _do_ make an actual commit. But that commit doesn't look
like a merge to the receiver; it just looks like a single commit that
has all the changes there were on PR-Branch.

The tree of that commit should be the same tree that would result from a
real merge. So in theory things like protected-branch status checks
could handle that, but I suspect they use the actual commit id (the tree
id is fine if you're just doing CI, but if you wanted to have a status
check for commit messages, say, you'd obviously want that to be tied to
the actual commit object).

I don't offhand recall how that is implemented (and you could also be
falling afoul of other checks, like required reviews). But this is a
GitHub-specific question, and you should probably ask GitHub support to
go further.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Squash & Merge Implementation
  2018-08-03 13:49 ` Jeff King
@ 2018-08-03 17:23   ` Vadim Belov
  0 siblings, 0 replies; 3+ messages in thread
From: Vadim Belov @ 2018-08-03 17:23 UTC (permalink / raw)
  To: peff; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 2463 bytes --]

Thanks, Peff!

I'm just doing the CI and the status check is for testing each commit to
the PR-Branch.
I'll try to get response from github on this as you suggested.

Thanks again,
Vadim

On Fri, Aug 3, 2018 at 4:49 PM Jeff King <peff@peff.net> wrote:

> On Fri, Aug 03, 2018 at 03:01:15PM +0300, Vadim Belov wrote:
>
> > 1. This merges successfully without squash:
> > git checkout origin/master
> > git merge ${PR-Branch}
> > git push origin HEAD:master
> > git push origin --delete ${PR-Branch}
>
> Right, this is a normal merge.
>
> > 2. This closes the PR, but there is no update seen on master:
> > git checkout origin/master
> > git merge --squash --commit ${PR-Branch}
> > git push origin HEAD:master
> > git push origin --delete ${PR-Branch}
>
> Doing "merge --squash --commit" doesn't do what you expect; namely
> "--commit" does not override the non-committing nature of "--squash". It
> only override a "--no-commit" found elsewhere.
>
> IMHO this is something that could be improved in Git (i.e., telling the
> difference between "the user did not say --no-commit" and "the user said
> --commit" and respecting it for --squash).
>
> But that explains what you see. The push to master is a noop, since you
> didn't make a new commit. And then deleting the PR branch on GitHub
> auto-closes the PR.
>
> > 3. This fails to push to master with the error "GH006: Protected branch
> > update failed"  (despite that the PR is set to SUCCESS):
> > git checkout origin/master
> > git merge --squash ${PR-Branch}
> > git commit -am"comment"
> > git push origin HEAD:${m_mainBranch}
> > git push origin --delete ${m_prBranch}
>
> So here you _do_ make an actual commit. But that commit doesn't look
> like a merge to the receiver; it just looks like a single commit that
> has all the changes there were on PR-Branch.
>
> The tree of that commit should be the same tree that would result from a
> real merge. So in theory things like protected-branch status checks
> could handle that, but I suspect they use the actual commit id (the tree
> id is fine if you're just doing CI, but if you wanted to have a status
> check for commit messages, say, you'd obviously want that to be tied to
> the actual commit object).
>
> I don't offhand recall how that is implemented (and you could also be
> falling afoul of other checks, like required reviews). But this is a
> GitHub-specific question, and you should probably ask GitHub support to
> go further.
>
> -Peff
>

[-- Attachment #2: Type: text/html, Size: 3104 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-08-03 17:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-03 12:01 Squash & Merge Implementation Vadim Belov
2018-08-03 13:49 ` Jeff King
2018-08-03 17:23   ` Vadim Belov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.