[cfe-dev] [Openmp-dev] [GitHub] RFC: Enforcing no merge commit policy

Tom Stellard via cfe-dev cfe-dev at lists.llvm.org
Mon Apr 15 20:52:44 PDT 2019


On 04/13/2019 05:13 PM, Mehdi AMINI wrote:
> 
> 
> On Sat, Apr 13, 2019 at 4:47 PM Mehdi AMINI <joker.eph at gmail.com <mailto:joker.eph at gmail.com>> wrote:
> 
> 
> 
>     On Tue, Apr 9, 2019 at 12:39 AM David Chisnall via cfe-dev <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
> 
>         On 09/04/2019 00:32, Tom Stellard via cfe-dev wrote:
>         > As a backup plan, I am going to look into implementing option #1, but instead
>         > of having git-llvm create a pull request, it would push first to a staging
>         > branch and then push to master if a 'no-merge commit' status checks pass.  This
>         > is essentially the same flow as using pull requests, but without all the
>         > pull request noise.
> 
>         I don't think that you can enforce this policy on the server side.  You
>         could; however, make git-llvm create a pull request and, if the relevant
>         checks pass, automatically use the GitHub APIs to do a rebase and merge.
> 
> 
>     I believe you can with: https://help.github.com/en/articles/enabling-required-status-checks
> 
>     I don't even think you need to push a branch for this*, the git-llvm script should be able to perform the required check locally, then issue a REST call and push to master.
> 
> 
> I just double-checked (I created a fake "rebased" check on my repo) and it still works as expected:
> 
> $ git push
> Enumerating objects: 5, done.
> Counting objects: 100% (5/5), done.
> Writing objects: 100% (3/3), 270 bytes | 270.00 KiB/s, done.
> Total 3 (delta 0), reused 0 (delta 0)
> remote: error: GH006: Protected branch update failed for refs/heads/master.
> remote: error: Required status check "rebased" is expected.
> To github.com:joker-eph/test_required_check.git
>  ! [remote rejected] master -> master (protected branch hook declined)
> error: failed to push some refs to 'git at github.com:joker-eph/test_required_check.git'
> 
> The `git llvm push` script could very well rebase, check the absence of merge commit, and issue this REST call:
> 
> $ curl   --user "{GitHub_username}"   -H "Authorization: token {GitHub token}"  https://api.github.com/repos/joker-eph/test_required_check/statuses/$(git <https://api.github.com/repos/joker-eph/test_required_check/statuses/$%28git> rev-list HEAD -n 1)  -X POST --data '{"state": "success", "context": "rebased" }'
> 

Ok, this would be much better than what I was proposing.  Thanks
for figuring this out.

-Tom

> After which the push is passing:
> 
> $ git push
> Enumerating objects: 5, done.
> Counting objects: 100% (5/5), done.
> Writing objects: 100% (3/3), 270 bytes | 270.00 KiB/s, done.
> Total 3 (delta 0), reused 0 (delta 0)
> To github.com:joker-eph/test_required_check.git
>    a07ce8f..2dd24ba  master -> master
> 
> -- 
> Mehdi




More information about the cfe-dev mailing list