2020-12-30 00:49:11 +00:00
|
|
|
package gitlab
|
|
|
|
|
2020-12-30 23:00:37 +00:00
|
|
|
import (
|
2024-07-18 04:25:13 +00:00
|
|
|
"path"
|
|
|
|
|
2024-08-04 19:44:50 +00:00
|
|
|
"github.com/badjware/gitlabfs/config"
|
2020-12-30 23:00:37 +00:00
|
|
|
"github.com/xanzy/go-gitlab"
|
|
|
|
)
|
2020-12-30 00:49:11 +00:00
|
|
|
|
|
|
|
type Project struct {
|
2021-01-18 05:24:26 +00:00
|
|
|
ID int
|
2024-07-18 04:25:13 +00:00
|
|
|
Path string
|
2021-01-18 05:24:26 +00:00
|
|
|
CloneURL string
|
|
|
|
DefaultBranch string
|
2020-12-30 00:49:11 +00:00
|
|
|
}
|
|
|
|
|
2024-05-05 20:09:03 +00:00
|
|
|
func (p *Project) GetRepositoryID() uint64 {
|
|
|
|
return uint64(p.ID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Project) GetCloneURL() string {
|
|
|
|
return p.CloneURL
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p *Project) GetDefaultBranch() string {
|
|
|
|
return p.DefaultBranch
|
|
|
|
}
|
|
|
|
|
2024-07-18 04:25:13 +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
|
2024-08-04 19:44:50 +00:00
|
|
|
if c.ArchivedProjectHandling == config.ArchivedProjectIgnore && project.Archived {
|
2024-07-18 04:25:13 +00:00
|
|
|
return nil
|
|
|
|
}
|
2020-12-30 23:00:37 +00:00
|
|
|
p := Project{
|
2021-01-18 05:24:26 +00:00
|
|
|
ID: project.ID,
|
2024-07-18 04:25:13 +00:00
|
|
|
Path: project.Path,
|
2021-01-18 05:24:26 +00:00
|
|
|
DefaultBranch: project.DefaultBranch,
|
|
|
|
}
|
|
|
|
if p.DefaultBranch == "" {
|
|
|
|
p.DefaultBranch = "master"
|
2020-12-30 00:49:11 +00:00
|
|
|
}
|
2024-08-04 19:44:50 +00:00
|
|
|
if c.PullMethod == config.PullMethodSSH {
|
2020-12-30 23:00:37 +00:00
|
|
|
p.CloneURL = project.SSHURLToRepo
|
|
|
|
} else {
|
|
|
|
p.CloneURL = project.HTTPURLToRepo
|
|
|
|
}
|
2024-08-04 19:44:50 +00:00
|
|
|
if c.ArchivedProjectHandling == config.ArchivedProjectHide && project.Archived {
|
2024-07-18 04:25:13 +00:00
|
|
|
p.Path = path.Join(path.Dir(p.Path), "."+path.Base(p.Path))
|
|
|
|
}
|
|
|
|
return &p
|
2020-12-30 00:49:11 +00:00
|
|
|
}
|