summaryrefslogtreecommitdiff
path: root/new.go
diff options
context:
space:
mode:
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