summaryrefslogtreecommitdiff
path: root/gitConfig.go
diff options
context:
space:
mode:
Diffstat (limited to 'gitConfig.go')
-rw-r--r--gitConfig.go85
1 files changed, 72 insertions, 13 deletions
diff --git a/gitConfig.go b/gitConfig.go
index f829c61..183479d 100644
--- a/gitConfig.go
+++ b/gitConfig.go
@@ -185,9 +185,11 @@ func (rs *RepoStatus) readGitConfig() error {
return nil
}
-// readGoMod reads and parses the go.sum file (TODO: do the go.mod file)
-func (rs *RepoStatus) ReadGoMod() bool {
- tmp := filepath.Join(rs.realPath.String(), "go.sum")
+// this checks to see if the repo is truly not dependent on _anything_ else
+// like spew or lib/widget
+func (rs *RepoStatus) CheckPrimativeGoMod() bool {
+ log.Log(WARN, "CheckPrimativeGoMod()", rs.realPath.String())
+ tmp := filepath.Join(rs.realPath.String(), "go.mod")
gomod, err := os.Open(tmp)
if err != nil {
log.Log(WARN, "missing go.mod", rs.realPath.String())
@@ -196,7 +198,32 @@ func (rs *RepoStatus) ReadGoMod() bool {
}
defer gomod.Close()
- tmp = filepath.Join(rs.realPath.String(), "go.sum")
+ scanner := bufio.NewScanner(gomod)
+ for scanner.Scan() {
+ line := strings.TrimSpace(scanner.Text())
+
+ parts := strings.Split(line, " ")
+ log.Log(WARN, " gomod:", parts)
+ if len(parts) >= 1 {
+ log.Log(WARN, " gomod: part[0] =", parts[0])
+ if parts[0] == "require" {
+ log.Log(WARN, " should return false here")
+ return false
+ }
+
+ }
+ }
+ return true
+}
+
+// readGoMod reads and parses the go.sum file (TODO: do the go.mod file)
+func (rs *RepoStatus) ReadGoMod() bool {
+ if rs.CheckPrimativeGoMod() {
+ log.Info("PRIMATIVE repo:", rs.String())
+ return true
+ }
+
+ tmp := filepath.Join(rs.realPath.String(), "go.sum")
gosum, err := os.Open(tmp)
if err != nil {
log.Log(WARN, "missing go.sum", rs.realPath.String())
@@ -257,14 +284,14 @@ func ScanGoSrc() {
func ScanGitConfig() {
/*
- for i, path := range listGitDirectories() {
- filename := filepath.Join(path, ".git/config")
- _, err := readGitConfig(filename)
- if err != nil {
- log.Log(WARN, "repo =", i, path)
- log.Log(WARN, "Error reading .git/config:", err)
+ for i, path := range listGitDirectories() {
+ filename := filepath.Join(path, ".git/config")
+ _, err := readGitConfig(filename)
+ if err != nil {
+ log.Log(WARN, "repo =", i, path)
+ log.Log(WARN, "Error reading .git/config:", err)
+ }
}
- }
*/
}
@@ -301,8 +328,8 @@ func (rs *RepoStatus) CheckGoSum() bool {
username := newrs.userWorkingName.String()
userhash, _ := newrs.gitConfig.hashes[username]
userversion, _ := newrs.gitConfig.versions[userhash]
- log.Log(WARN, " username :" + username, userhash)
- log.Log(WARN, " username :" + username, userversion)
+ log.Log(WARN, " username :"+username, userhash)
+ log.Log(WARN, " username :"+username, userversion)
if version == userversion {
log.Log(WARN, " USER VERSIONS MATCH", version, userversion)
} else {
@@ -311,12 +338,44 @@ func (rs *RepoStatus) CheckGoSum() bool {
}
} else {
log.Log(WARN, " NOT FOUND", depname)
+ log.Log(WARN, " go get -v", depname)
+ rs.RunCmd([]string{"go", "get", "-v", depname})
return false
}
}
return true
}
+func (rs *RepoStatus) MakeRedomod() {
+ var err error
+ var b bool
+ var output string
+ var worked bool = true
+
+ os.Unsetenv("GO111MODULE")
+ path := rs.realPath.String()
+ err, b, output = RunCmd(path, []string{"rm", "-f", "go.mod", "go.sum"})
+ if err != nil {
+ worked = false
+ log.Log(WARN, "rm failed", err, b, output)
+ }
+ err, b, output = RunCmd(path, []string{"go", "mod", "init"})
+ if err != nil {
+ worked = false
+ log.Log(WARN, "go mod init failed", err, b, output)
+ }
+ err, b, output = RunCmd(path, []string{"go", "mod", "tidy"})
+ if err != nil {
+ worked = false
+ log.Log(WARN, "go mod tidy failed", err, b, output)
+ }
+ if worked {
+ log.Log(WARN, "MakeRedomod() worked", path)
+ } else {
+ log.Log(WARN, "MakeRedomod() failed", path)
+ }
+}
+
func (rs *RepoStatus) processBranch(branch string) {
fullpath := rs.realPath.String()
log.Log(WARN, " ", branch)