add SetGoPrimitive()
This commit is contained in:
parent
5434341272
commit
ea14fc629d
2
main.go
2
main.go
|
@ -91,7 +91,7 @@ func findPwdRepo() *gitpb.Repo {
|
||||||
|
|
||||||
func saveAsMetadata(repo *gitpb.Repo) error {
|
func saveAsMetadata(repo *gitpb.Repo) error {
|
||||||
cname := repo.GetCurrentBranchName()
|
cname := repo.GetCurrentBranchName()
|
||||||
if repo.GoInfo.GoPrimitive {
|
if repo.GetGoPrimitive() {
|
||||||
if err := repo.AutogenSave([]string{"go.mod"}, cname, true); err != nil {
|
if err := repo.AutogenSave([]string{"go.mod"}, cname, true); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
18
redoGoMod.go
18
redoGoMod.go
|
@ -53,28 +53,30 @@ func redoGoMod(repo *gitpb.Repo) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
repo.GoDeps = nil
|
repo.GoDeps = nil
|
||||||
repo.GoInfo.GoPrimitive = false
|
repo.SetGoPrimitive(false)
|
||||||
|
|
||||||
// if there is not a go.sum file, it better be a primitive golang project
|
// if there is not a go.sum file, it better be a primitive golang project
|
||||||
if !repo.Exists("go.sum") {
|
if !repo.Exists("go.sum") {
|
||||||
// todo. fix this logic
|
// todo. fix this logic
|
||||||
ok, err := repo.IsPrimitive()
|
err := repo.SetPrimitive()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// this means this repo does not depend on any other package
|
// this means this repo does not depend on any other package
|
||||||
log.Info("PRIMATIVE repo error:", repo.GetGoPath(), "err =", err)
|
log.Info("PRIMATIVE repo error:", repo.GetGoPath(), "err =", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ok {
|
// now check if GoPrimitive is true
|
||||||
// this means the repo is primitive so there is no go.sum
|
if repo.GetGoPrimitive() {
|
||||||
repo.GoInfo.GoPrimitive = true
|
// perfect!
|
||||||
repo.GoDeps = new(gitpb.GoDeps)
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
// well, it's not a primitive and we are still missing the go.sum file
|
||||||
if !repo.Exists("go.sum") {
|
if !repo.Exists("go.sum") {
|
||||||
// this should never happen
|
// this means something else went wrong!
|
||||||
|
// display the go.mod file and try to figure out what happened
|
||||||
|
// maybe the format of go.mod changed in some future version of golang
|
||||||
data, _ := repo.ReadFile("go.mod")
|
data, _ := repo.ReadFile("go.mod")
|
||||||
log.Info(string(data))
|
log.Info(string(data))
|
||||||
return errors.New("missing go.sum file on non-primitive go.mod")
|
return errors.New("missing go.sum file on non-primitive go.mod")
|
||||||
|
|
Loading…
Reference in New Issue