From 804acc169a49320a5f9a0efb60847071f7fee7f2 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 9 Mar 2024 22:03:18 -0600 Subject: [PATCH] fix logic for go.work setups --- git.go | 3 +++ unix.go | 8 +------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/git.go b/git.go index a8ba548..f51d74d 100644 --- a/git.go +++ b/git.go @@ -298,6 +298,9 @@ func (rs *RepoStatus) CheckoutUser() bool { log.Log(REPO, rs.realPath.String(), "is dirty") return false } + if ! rs.BranchExists(bName) { + return false + } cmd := []string{"git", "checkout", bName} err, b, output := RunCmd(rs.realPath.String(), cmd) if err != nil { diff --git a/unix.go b/unix.go index a3b1647..1929d24 100644 --- a/unix.go +++ b/unix.go @@ -6,7 +6,6 @@ import ( "io/ioutil" "os" "os/exec" - "os/user" "path/filepath" "regexp" "strconv" @@ -222,12 +221,7 @@ func IsDirectory(path string) bool { } func (rs *RepoStatus) Exists(filename string) bool { - usr, err := user.Current() - 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) + testf := filepath.Join(rs.Path(), filename) if Exists(testf) { return true }