summaryrefslogtreecommitdiff
path: root/new.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-23 10:52:17 -0600
committerJeff Carr <[email protected]>2024-01-23 10:52:17 -0600
commit294119e7c2678b609aa8b66b6ffc219f1c399309 (patch)
tree1a0b9e7de365e6540d0b3f9cc762a852472e32f6 /new.go
parent7546209d24055bb1252ba3cab63e09f692c3e74b (diff)
buttons for scanning .git/config and go.sum
common branch handling scan go.sum & .git/config on New() parse go & git config files cleaner debugging cleaning up logging Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'new.go')
-rw-r--r--new.go33
1 files changed, 32 insertions, 1 deletions
diff --git a/new.go b/new.go
index 5da1fc1..c7c41d2 100644
--- a/new.go
+++ b/new.go
@@ -1,6 +1,9 @@
package repostatus
import (
+ "os"
+ "path/filepath"
+
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/log"
@@ -16,12 +19,40 @@ func ListAll() {
func NewRepoStatusWindow(path string) *RepoStatus {
if windowMap[path] == nil {
- log.Warn("This doesn't exist yet for path", path)
+ log.Log(INFO, "NewRepoStatusWindow() adding new", path)
} else {
log.Warn("This already exists yet for path", path)
log.Warn("should return windowMap[path] here")
+ return windowMap[path]
+ }
+
+ homeDir, err := os.UserHomeDir()
+ if err != nil {
+ log.Log(WARN, "Error getting home directory:", err)
+ return nil
}
+
+ goSrcDir := filepath.Join(homeDir, "go/src")
+
+ realpath := filepath.Join(goSrcDir, path)
+ filename := filepath.Join(realpath, ".git/config")
+ gitConfig, err := readGitConfig(filename)
+
+ // if the .git/config file fails to load, just nil out man
+ if err != nil {
+ log.Log(WARN, "Error reading .git/config:", err)
+ return nil
+ }
+
rs := New(gui.TreeRoot(), path)
+
+ // save ~/go/src & the whole path strings
+ rs.goSrcPath.SetValue(goSrcDir)
+ rs.realPath.SetValue(realpath)
+
+ // save .git/config
+ rs.gitConfig = gitConfig
+
windowMap[path] = rs
// todo check if a window already exists for this path