fix default initial branch ignoring the project default branch and always be set to master
This commit is contained in:
parent
4d504d9f5a
commit
ab4d1d6a7e
|
@ -29,7 +29,7 @@ func newRepositoryNode(project *gitlab.Project, param *FSParam) (*RepositoryNode
|
|||
|
||||
func (n *RepositoryNode) Readlink(ctx context.Context) ([]byte, syscall.Errno) {
|
||||
// Create the local copy of the repo
|
||||
localRepoLoc, _ := n.param.Git.CloneOrPull(n.project.CloneURL, n.project.ID, "master")
|
||||
localRepoLoc, _ := n.param.Git.CloneOrPull(n.project.CloneURL, n.project.ID, n.project.DefaultBranch)
|
||||
|
||||
return []byte(localRepoLoc), 0
|
||||
}
|
||||
|
|
|
@ -82,9 +82,12 @@ func (c *gitClient) clone(gcp *gitCloneParam) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to retrieve worktree of git repo %v: %v", gcp.dst, err)
|
||||
}
|
||||
w.Checkout(&git.CheckoutOptions{
|
||||
err = w.Checkout(&git.CheckoutOptions{
|
||||
Branch: branchRef,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to checkout %v of git repo %v: %v", branchRef, gcp.dst, err)
|
||||
}
|
||||
}
|
||||
if c.PullAfterClone {
|
||||
// Dispatch to pull worker
|
||||
|
|
|
@ -8,6 +8,7 @@ type Project struct {
|
|||
ID int
|
||||
Name string
|
||||
CloneURL string
|
||||
DefaultBranch string
|
||||
}
|
||||
|
||||
func (c *gitlabClient) newProjectFromGitlabProject(project *gitlab.Project) Project {
|
||||
|
@ -15,6 +16,10 @@ func (c *gitlabClient) newProjectFromGitlabProject(project *gitlab.Project) Proj
|
|||
p := Project{
|
||||
ID: project.ID,
|
||||
Name: project.Path,
|
||||
DefaultBranch: project.DefaultBranch,
|
||||
}
|
||||
if p.DefaultBranch == "" {
|
||||
p.DefaultBranch = "master"
|
||||
}
|
||||
if c.PullMethod == PullMethodSSH {
|
||||
p.CloneURL = project.SSHURLToRepo
|
||||
|
|
Loading…
Reference in New Issue