Skip to content

Commit 184826b

Browse files
committed
Add sync a fork branch with the upstream repository
1 parent 3467a34 commit 184826b

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lib/Github/Api/Repo.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,25 @@ public function branches($username, $repository, $branch = null, array $paramete
535535
return $this->get($url, $parameters);
536536
}
537537

538+
/**
539+
* Sync a fork branch with the upstream repository.
540+
*
541+
* @link https://docs.github.com/en/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository
542+
*
543+
* @param string $username
544+
* @param string $repository
545+
* @param string|null $branchName
546+
*
547+
* @return array|string
548+
*/
549+
public function mergeUpstream($username, $repository, $branchName = null)
550+
{
551+
return $this->post(
552+
'/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/merge-upstream',
553+
['branch' => $branchName ?? 'main']
554+
);
555+
}
556+
538557
/**
539558
* Manage the protection of a repository branch.
540559
*

0 commit comments

Comments
 (0)