Don't die for bad aliases
This commit is contained in:
parent
abdfea8153
commit
ea7367ec08
@ -114,6 +114,7 @@ Use "gitlab-project-manager cache [command] --help" for more information about a
|
|||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
|
- [ ] Don't check remote up unless necessary (project list shouldn't require it)
|
||||||
- [ ] Rename to git-project-manager
|
- [ ] Rename to git-project-manager
|
||||||
- [ ] Move module from gitlab.sweetwater.com to github.com/rdmcguire
|
- [ ] Move module from gitlab.sweetwater.com to github.com/rdmcguire
|
||||||
- [ ] Add flag for clone timeout for large repos
|
- [ ] Add flag for clone timeout for large repos
|
||||||
|
@ -111,7 +111,7 @@ ALIASES:
|
|||||||
for _, a := range aliases {
|
for _, a := range aliases {
|
||||||
for _, p := range projects {
|
for _, p := range projects {
|
||||||
// Already have it
|
// Already have it
|
||||||
if a.ProjectID == p.ID && a.Remote == p.Remote {
|
if p == nil || (a.ProjectID == p.ID && a.Remote == p.Remote) {
|
||||||
continue ALIASES
|
continue ALIASES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
4
go.mod
4
go.mod
@ -20,7 +20,7 @@ require (
|
|||||||
atomicgo.dev/cursor v0.2.0 // indirect
|
atomicgo.dev/cursor v0.2.0 // indirect
|
||||||
atomicgo.dev/keyboard v0.2.9 // indirect
|
atomicgo.dev/keyboard v0.2.9 // indirect
|
||||||
atomicgo.dev/schedule v0.1.0 // indirect
|
atomicgo.dev/schedule v0.1.0 // indirect
|
||||||
code.gitea.io/sdk/gitea v0.17.1 // indirect
|
code.gitea.io/sdk/gitea v0.17.1 // direct
|
||||||
dario.cat/mergo v1.0.0 // indirect
|
dario.cat/mergo v1.0.0 // indirect
|
||||||
github.com/Microsoft/go-winio v0.6.1 // indirect
|
github.com/Microsoft/go-winio v0.6.1 // indirect
|
||||||
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
|
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
|
||||||
@ -37,7 +37,7 @@ require (
|
|||||||
github.com/go-git/go-billy/v5 v5.5.0 // indirect
|
github.com/go-git/go-billy/v5 v5.5.0 // indirect
|
||||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||||
github.com/golang/protobuf v1.5.3 // indirect
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
github.com/google/go-github/v58 v58.0.0 // indirect
|
github.com/google/go-github/v58 v58.0.0 // direct
|
||||||
github.com/google/go-querystring v1.1.0 // indirect
|
github.com/google/go-querystring v1.1.0 // indirect
|
||||||
github.com/gookit/color v1.5.4 // indirect
|
github.com/gookit/color v1.5.4 // indirect
|
||||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||||
|
2
go.sum
2
go.sum
@ -360,8 +360,6 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0
|
|||||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
||||||
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=
|
||||||
golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY=
|
|
||||||
golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
|
||||||
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||||
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
11
internal/cache/projects_alias.go
vendored
11
internal/cache/projects_alias.go
vendored
@ -27,6 +27,9 @@ func (c *Cache) GetProjectAliasStrings(project *projects.Project) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Cache) GetProjectStringWithAliases(project *projects.Project) string {
|
func (c *Cache) GetProjectStringWithAliases(project *projects.Project) string {
|
||||||
|
if project == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
aliases := c.GetProjectAliasStrings(project)
|
aliases := c.GetProjectAliasStrings(project)
|
||||||
return fmt.Sprintf("%s (%s) -> %s",
|
return fmt.Sprintf("%s (%s) -> %s",
|
||||||
project.Name,
|
project.Name,
|
||||||
@ -102,9 +105,11 @@ func (c *Cache) GetProjectByAlias(alias *ProjectAlias) *projects.Project {
|
|||||||
|
|
||||||
func (c *Cache) GetProjectAliases(project *projects.Project) []*ProjectAlias {
|
func (c *Cache) GetProjectAliases(project *projects.Project) []*ProjectAlias {
|
||||||
aliases := make([]*ProjectAlias, 0)
|
aliases := make([]*ProjectAlias, 0)
|
||||||
for _, alias := range c.Aliases {
|
if project != nil {
|
||||||
if alias.ProjectID == project.ID {
|
for _, alias := range c.Aliases {
|
||||||
aliases = append(aliases, alias)
|
if alias.ProjectID == project.ID {
|
||||||
|
aliases = append(aliases, alias)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return aliases
|
return aliases
|
||||||
|
Loading…
Reference in New Issue
Block a user