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);
    }
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);
    }
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 ) ; }
Get the upstream for a branch.

@param string      $branch
The name of the branch to get the upstream for. Defaults to the current
branch.
@param string|null $dir
The path to a Git repository.
@param bool        $mustRun
Enable exceptions if the Git command fails.

@return string|false
The upstream, in the form remote/branch, or false if no upstream is
found.
Get the upstream for a branch .