fix logic for go.work setups

This commit is contained in:
Jeff Carr 2024-03-09 22:03:18 -06:00
parent 2622e90b1f
commit 804acc169a
2 changed files with 4 additions and 7 deletions

3
git.go
View File

@ -298,6 +298,9 @@ func (rs *RepoStatus) CheckoutUser() bool {
log.Log(REPO, rs.realPath.String(), "is dirty") log.Log(REPO, rs.realPath.String(), "is dirty")
return false return false
} }
if ! rs.BranchExists(bName) {
return false
}
cmd := []string{"git", "checkout", bName} cmd := []string{"git", "checkout", bName}
err, b, output := RunCmd(rs.realPath.String(), cmd) err, b, output := RunCmd(rs.realPath.String(), cmd)
if err != nil { if err != nil {

View File

@ -6,7 +6,6 @@ import (
"io/ioutil" "io/ioutil"
"os" "os"
"os/exec" "os/exec"
"os/user"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strconv" "strconv"
@ -222,12 +221,7 @@ func IsDirectory(path string) bool {
} }
func (rs *RepoStatus) Exists(filename string) bool { func (rs *RepoStatus) Exists(filename string) bool {
usr, err := user.Current() testf := filepath.Join(rs.Path(), filename)
if err != nil {
log.Error(err, "Exists() error: could not determine what your username is")
return false
}
testf := filepath.Join(usr.HomeDir, "go/src/", rs.String(), filename)
if Exists(testf) { if Exists(testf) {
return true return true
} }