git - libgit2sharp what is correct sha to supply to GitHub API merge pull-request? -


github api requires merge pull-request submitted

put /repos/:owner/:repo/pulls/:number/merge 

with request body json

{   "commit_message": "blah",   "sha": "{sha pull request head must match allow merge}", } 

following commit, push, create pr, libgit2sharp property supplies correct sha ?

for current branch, appears branch.tip.sha correct value, i'm receiving response error :

{ "message": "head branch modified. review , try merge again.", "documentation_url": "https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button" }

two different commits , shas come play when comes pull request.

when leveraging github api merge opened pull request, optional sha property json payload expected match sha of branch tip as known github.

provided local repository in sync github knows repository, should matching repo.branches["your_topic_branch"].tip.sha returns.

note: in order ensure github known head of pr matches local branch tip, using libgit2sharp, can retrieve github pr merge/head pointed @ commits, directly fetching special reference namespace. following code demonstrates this

var remotename = "origin"; // or whatever remote named var remote = repo.network.remotes[remotename]; var prnumber = "1123"; // or whatever pr number  // build refspec string refspec = string.format("+refs/pull/{1}/*:refs/remotes/{0}/pull/{1}/*",                          remotename, prnumber);  // perform actual fetch repo.network.fetch(remote, new[] { refspec });  console.writeline(repo.branches[string.format("pull/{0}/merge", prnumber)].tip.sha); 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -