Skip to content

Commit 0b526e0

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

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

lib/Github/Api/Repo.php

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

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

0 commit comments

Comments
 (0)