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) {
|
func (n *RepositoryNode) Readlink(ctx context.Context) ([]byte, syscall.Errno) {
|
||||||
// Create the local copy of the repo
|
// 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
|
return []byte(localRepoLoc), 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,9 +82,12 @@ func (c *gitClient) clone(gcp *gitCloneParam) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to retrieve worktree of git repo %v: %v", gcp.dst, err)
|
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,
|
Branch: branchRef,
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to checkout %v of git repo %v: %v", branchRef, gcp.dst, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if c.PullAfterClone {
|
if c.PullAfterClone {
|
||||||
// Dispatch to pull worker
|
// Dispatch to pull worker
|
||||||
|
|
|
@ -5,16 +5,21 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Project struct {
|
type Project struct {
|
||||||
ID int
|
ID int
|
||||||
Name string
|
Name string
|
||||||
CloneURL string
|
CloneURL string
|
||||||
|
DefaultBranch string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *gitlabClient) newProjectFromGitlabProject(project *gitlab.Project) Project {
|
func (c *gitlabClient) newProjectFromGitlabProject(project *gitlab.Project) Project {
|
||||||
// https://godoc.org/github.com/xanzy/go-gitlab#Project
|
// https://godoc.org/github.com/xanzy/go-gitlab#Project
|
||||||
p := Project{
|
p := Project{
|
||||||
ID: project.ID,
|
ID: project.ID,
|
||||||
Name: project.Path,
|
Name: project.Path,
|
||||||
|
DefaultBranch: project.DefaultBranch,
|
||||||
|
}
|
||||||
|
if p.DefaultBranch == "" {
|
||||||
|
p.DefaultBranch = "master"
|
||||||
}
|
}
|
||||||
if c.PullMethod == PullMethodSSH {
|
if c.PullMethod == PullMethodSSH {
|
||||||
p.CloneURL = project.SSHURLToRepo
|
p.CloneURL = project.SSHURLToRepo
|
||||||
|
|
Loading…
Reference in New Issue