diff --git a/fs/repository.go b/fs/repository.go index 0bfe05e..5370473 100644 --- a/fs/repository.go +++ b/fs/repository.go @@ -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 } diff --git a/gitlab/project.go b/gitlab/project.go index 7432bab..6f789f5 100644 --- a/gitlab/project.go +++ b/gitlab/project.go @@ -5,16 +5,21 @@ import ( ) type Project struct { - ID int - Name string - CloneURL string + ID int + Name string + CloneURL string + DefaultBranch string } func (c *gitlabClient) newProjectFromGitlabProject(project *gitlab.Project) Project { // https://godoc.org/github.com/xanzy/go-gitlab#Project p := Project{ - ID: project.ID, - Name: project.Path, + ID: project.ID, + Name: project.Path, + DefaultBranch: project.DefaultBranch, + } + if p.DefaultBranch == "" { + p.DefaultBranch = "master" } if c.PullMethod == PullMethodSSH { p.CloneURL = project.SSHURLToRepo