Return a fully remote ref to reduce chances of ref clashes

This commit is contained in:
risk danger olson 2016-05-24 16:55:31 -06:00
parent ac1a10919e
commit 04db42054e
2 changed files with 4 additions and 3 deletions

@ -116,7 +116,8 @@ func RemoteForCurrentBranch() (string, error) {
return remote, nil
}
// RemoteRefForCurrentBranch returns the full remote ref (remote/remotebranch) that the current branch is tracking
// RemoteRefForCurrentBranch returns the full remote ref (refs/remotes/{remote}/{remotebranch})
// that the current branch is tracking.
func RemoteRefNameForCurrentBranch() (string, error) {
ref, err := CurrentRef()
if err != nil {
@ -134,7 +135,7 @@ func RemoteRefNameForCurrentBranch() (string, error) {
remotebranch := RemoteBranchForLocalBranch(ref.Name)
return remote + "/" + remotebranch, nil
return fmt.Sprintf("refs/remotes/%s/%s", remote, remotebranch), nil
}
// RemoteForBranch returns the remote name that a given local branch is tracking (blank if none)

@ -66,7 +66,7 @@ func TestCurrentRefAndCurrentRemoteRef(t *testing.T) {
refname, err := RemoteRefNameForCurrentBranch()
assert.Equal(t, nil, err)
assert.Equal(t, "origin/someremotebranch", refname)
assert.Equal(t, "refs/remotes/origin/someremotebranch", refname)
remote, err := RemoteForCurrentBranch()
assert.Equal(t, nil, err)