Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

Commit

Permalink
fix ref spec
Browse files Browse the repository at this point in the history
  • Loading branch information
rajatjindal committed Oct 5, 2019
1 parent ae83618 commit 4c7d973
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 6 additions & 10 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package git

import (
"fmt"
"os"
"time"

Expand Down Expand Up @@ -56,15 +57,6 @@ func FetchUpstream(remote *ugit.Remote, remoteName string) error {
})
}

//Push push code
func Push(repo *ugit.Repository, remoteName string) error {
return repo.Push(&ugit.PushOptions{
RemoteName: remoteName,
RefSpecs: []config.RefSpec{config.DefaultPushRefSpec},
Auth: getAuth(),
})
}

//CreateBranch creates branch
func CreateBranch(repo *ugit.Repository, branchName string) error {
w, err := repo.Worktree()
Expand Down Expand Up @@ -121,7 +113,7 @@ func AddCommitAndPush(repo *ugit.Repository, commitMsg, remoteName, branchName s

return repo.Push(&ugit.PushOptions{
RemoteName: remoteName,
RefSpecs: []config.RefSpec{config.DefaultPushRefSpec},
RefSpecs: []config.RefSpec{getRefSpec(remoteName, branchName)},
Auth: getAuth(),
})
}
Expand All @@ -138,3 +130,7 @@ func PullRebase(repo *ugit.Repository, remoteName, branchName string) error {
Auth: getAuth(),
})
}

func getRefSpec(remoteName, branchName string) config.RefSpec {
return config.RefSpec(fmt.Sprintf("refs/heads/%s:refs/heads/%s/%s", branchName, remoteName, branchName))
}
2 changes: 2 additions & 0 deletions vendor/gopkg.in/src-d/go-git.v4/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4c7d973

Please sign in to comment.