Skip to content

Commit

Permalink
Add support for merge-upstream Repository action
Browse files Browse the repository at this point in the history
It's now possible to trigger a merge from upstream on a branch directly
via the API rather than trying to compare commit hashes and editing
refs. This commit adds support for the new action.
  • Loading branch information
Ryan Egesdahl committed Sep 29, 2021
1 parent 83d6e07 commit 0d41822
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
13 changes: 13 additions & 0 deletions github/Repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -3353,6 +3353,19 @@ def merge(self, base, head, commit_message=github.GithubObject.NotSet):
else:
return github.Commit.Commit(self._requester, headers, data, completed=True)

def merge_upstream(self, branch):
"""
:calls: `POST /repos/{owner}/{repo}/merge-upstream <http://docs.github.com/en/rest/reference/repos#sync-a-fork-branch-with-the-upstream-repository>`_
:param branch: string
:rtype: bool
"""
assert isinstance(branch, str), branch
post_parameters = {"branch": branch}
status, _, _ = self._requester.requestJson(
"POST", f"{self.url}/merge-upstream", input=post_parameters
)
return status == 200

def replace_topics(self, topics):
"""
:calls: `PUT /repos/{owner}/{repo}/topics <http://docs.github.com/en/rest/reference/repos>`_
Expand Down

0 comments on commit 0d41822

Please sign in to comment.