always run goimports. misc other changes
This commit is contained in:
parent
4a64e3a7c2
commit
77cd0ae36e
2
Makefile
2
Makefile
|
@ -5,7 +5,7 @@
|
|||
# go install
|
||||
|
||||
|
||||
all: gitTag.pb.go goDep.pb.go repo.pb.go vet
|
||||
all: goimports gitTag.pb.go goDep.pb.go repo.pb.go vet
|
||||
|
||||
vet:
|
||||
@GO111MODULE=off go vet
|
||||
|
|
|
@ -35,11 +35,22 @@ func (repo *Repo) CheckDirty() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
if len(r.Stdout) == 0 {
|
||||
repo.Dirty = false
|
||||
return false
|
||||
// dirty if anything but go.mod and go.sum
|
||||
var bad bool = false
|
||||
for _, line := range r.Stdout {
|
||||
parts := strings.Fields(line)
|
||||
if len(parts) == 2 {
|
||||
switch parts[1] {
|
||||
case "go.mod":
|
||||
case "go.sum":
|
||||
default:
|
||||
bad = true
|
||||
}
|
||||
} else {
|
||||
bad = true
|
||||
}
|
||||
}
|
||||
repo.Dirty = true
|
||||
return true
|
||||
|
||||
return bad
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ package gitpb
|
|||
import (
|
||||
"errors"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
@ -67,41 +66,6 @@ func (repo *Repo) RedoGoMod() (bool, error) {
|
|||
return false, errors.New("MakeRedomod() logic failed")
|
||||
}
|
||||
|
||||
func (repo *Repo) RepoType() string {
|
||||
if repo == nil {
|
||||
return "nil"
|
||||
}
|
||||
if repo.GetGoPlugin() {
|
||||
return "plugin"
|
||||
}
|
||||
if repo.GetGoBinary() {
|
||||
return "binary"
|
||||
}
|
||||
if ok, _, _ := repo.IsProtobuf(); ok {
|
||||
return "protobuf"
|
||||
}
|
||||
if repo.GetGoLibrary() {
|
||||
return "library"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (repo *Repo) goListRepoType() string {
|
||||
os.Setenv("GO111MODULE", "off")
|
||||
cmd := []string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"}
|
||||
// cmd := []string{"go", "list", "-f", "'{{.Name}}'"} // probably use this. this just prints out the package name
|
||||
// cmd := []string{"go", "list", "-f", "'{{.ImportPath}}'"} // returns go.wit.com/lib/protobuf/gitpb
|
||||
|
||||
result := repo.RunQuiet(cmd)
|
||||
if result.Error != nil {
|
||||
log.Warn("go list binary detect failed", result.Error)
|
||||
return ""
|
||||
}
|
||||
output := strings.TrimSpace(strings.Join(result.Stdout, "\n"))
|
||||
output = strings.Trim(output, "'")
|
||||
return output
|
||||
}
|
||||
|
||||
// returns true if the last published
|
||||
func (repo *Repo) GoDepsLen() int {
|
||||
if repo.GoDeps == nil {
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package gitpb
|
||||
|
||||
// does processing on the go.mod and go.sum files
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func (repo *Repo) RepoType() string {
|
||||
if repo == nil {
|
||||
return "nil"
|
||||
}
|
||||
if repo.GetGoPlugin() {
|
||||
return "plugin"
|
||||
}
|
||||
if repo.GetGoBinary() {
|
||||
if repo.Exists(".plugin") {
|
||||
return "plugin"
|
||||
}
|
||||
return "binary"
|
||||
}
|
||||
if ok, _, _ := repo.IsProtobuf(); ok {
|
||||
return "protobuf"
|
||||
}
|
||||
if repo.GetGoLibrary() {
|
||||
return "library"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (repo *Repo) goListRepoType() string {
|
||||
os.Setenv("GO111MODULE", "off")
|
||||
cmd := []string{"go", "list", "-f", "'{{if eq .Name \"main\"}}binary{{else}}library{{end}}'"}
|
||||
// cmd := []string{"go", "list", "-f", "'{{.Name}}'"} // probably use this. this just prints out the package name
|
||||
// cmd := []string{"go", "list", "-f", "'{{.ImportPath}}'"} // returns go.wit.com/lib/protobuf/gitpb
|
||||
|
||||
result := repo.RunQuiet(cmd)
|
||||
if result.Error != nil {
|
||||
log.Warn("go list binary detect failed", result.Error)
|
||||
return ""
|
||||
}
|
||||
output := strings.TrimSpace(strings.Join(result.Stdout, "\n"))
|
||||
output = strings.Trim(output, "'")
|
||||
return output
|
||||
}
|
2
shell.go
2
shell.go
|
@ -54,13 +54,11 @@ func (repo *Repo) strictRun(cmd []string) (bool, error) {
|
|||
|
||||
func (repo *Repo) Exists(filename string) bool {
|
||||
if repo == nil {
|
||||
log.Warn("repo == nil for Exists()")
|
||||
return false
|
||||
}
|
||||
testf := filepath.Join(repo.FullPath, filename)
|
||||
_, err := os.Stat(testf)
|
||||
if err != nil {
|
||||
log.Warn("gitpb: Exists() failed for", testf)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
|
Loading…
Reference in New Issue