avoid a few nil's
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
4beeb0bb13
commit
86136ce615
14
git.go
14
git.go
|
@ -153,6 +153,20 @@ func (rs *RepoStatus) checkoutBranch(level string, branch string) {
|
|||
}
|
||||
|
||||
func (rs *RepoStatus) SetMainWorkingName(s string) {
|
||||
if rs == nil {
|
||||
log.Info("rs == nil", s)
|
||||
return
|
||||
}
|
||||
if rs.gitConfig == nil {
|
||||
log.Info("rs.gitConfig == nil", s)
|
||||
rs.mainWorkingName.SetValue(s)
|
||||
return
|
||||
}
|
||||
if rs.gitConfig.branches == nil {
|
||||
log.Info("rs.gitConfig.branches == nil", s)
|
||||
rs.mainWorkingName.SetValue(s)
|
||||
return
|
||||
}
|
||||
_, ok := rs.gitConfig.branches[s]
|
||||
if ok {
|
||||
log.Info("git branch", s, "seems to exist")
|
||||
|
|
|
@ -79,7 +79,13 @@ func (rs *RepoStatus) readGitConfig() error {
|
|||
filename := filepath.Join(rs.realPath.String(), "/.git/config")
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
return nil
|
||||
filename = filepath.Join(rs.realPath.String(), "../.git/config")
|
||||
log.Log(WARN, "readGitConfig() trying up one directory instead", filename)
|
||||
file, err = os.Open(filename)
|
||||
if err != nil {
|
||||
panic("couldn't open .git/config")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
|
|
5
new.go
5
new.go
|
@ -40,8 +40,9 @@ func NewRepoStatusWindow(path string) *RepoStatus {
|
|||
|
||||
_, err = os.Open(filename)
|
||||
if err != nil {
|
||||
log.Log(WARN, "Error reading:", filename, err)
|
||||
return nil
|
||||
log.Log(WARN, "Error reading .git/config:", filename, err)
|
||||
log.Log(WARN, "TODO: find .git/config in parent directory")
|
||||
// return nil
|
||||
}
|
||||
|
||||
rs := New(gui.TreeRoot(), path)
|
||||
|
|
13
unix.go
13
unix.go
|
@ -222,9 +222,18 @@ func VerifyLocalGoRepo(gorepo string) bool {
|
|||
|
||||
// Form the path to the home Git directory
|
||||
gitDir := filepath.Join(usr.HomeDir, "go/src/", gorepo, ".git")
|
||||
|
||||
log.Log(WARN, "VerifyLocalGoRepo() checking directory:", gitDir)
|
||||
return IsDirectory(gitDir)
|
||||
if IsDirectory(gitDir) {
|
||||
return true
|
||||
}
|
||||
goDir := filepath.Join(usr.HomeDir, "go/src/", gorepo)
|
||||
gomod := goDir + "/go.mod"
|
||||
log.Log(WARN, "VerifyLocalGoRepo() checking for go.mod :", gomod)
|
||||
_, err = os.Stat(gomod)
|
||||
if os.IsNotExist(err) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func readFileToString(filename string) (string, error) {
|
||||
|
|
Loading…
Reference in New Issue