gitforgefs/gitlab/project.go

31 lines
623 B
Go
Raw Normal View History

2020-12-30 00:49:11 +00:00
package gitlab
2020-12-30 23:00:37 +00:00
import (
"github.com/xanzy/go-gitlab"
)
2020-12-30 00:49:11 +00:00
type Project struct {
ID int
Name string
CloneURL string
DefaultBranch string
2020-12-30 00:49:11 +00:00
}
2020-12-30 23:00:37 +00:00
func (c *gitlabClient) newProjectFromGitlabProject(project *gitlab.Project) Project {
2020-12-30 00:49:11 +00:00
// https://godoc.org/github.com/xanzy/go-gitlab#Project
2020-12-30 23:00:37 +00:00
p := Project{
ID: project.ID,
Name: project.Path,
DefaultBranch: project.DefaultBranch,
}
if p.DefaultBranch == "" {
p.DefaultBranch = "master"
2020-12-30 00:49:11 +00:00
}
2020-12-30 23:00:37 +00:00
if c.PullMethod == PullMethodSSH {
p.CloneURL = project.SSHURLToRepo
} else {
p.CloneURL = project.HTTPURLToRepo
}
return p
2020-12-30 00:49:11 +00:00
}