public function getUpstream($branch = null, $dir = null, $mustRun = false)
{
if ($branch === null) {
$args = ['rev-parse', '--abbrev-ref', '--symbolic-full-name', '@{u}'];
return $this->execute($args, $dir, $mustRun);
}
$remoteName = $this->getConfig("branch.{$branch}.remote", $dir, $mustRun);
$remoteBranch = $this->getConfig("branch.{$branch}.merge", $dir, $mustRun);
if (empty($remoteName) || empty($remoteBranch)) {
return false;
}
return $remoteName . '/' . str_replace('refs/heads/', '', $remoteBranch);
}