diff options
Diffstat (limited to 'new.go')
| -rw-r--r-- | new.go | 43 |
1 files changed, 35 insertions, 8 deletions
@@ -11,6 +11,10 @@ import ( var windowMap map[string]*RepoStatus +func init() { + windowMap = make(map[string]*RepoStatus) +} + func ListAll() { for path, rs := range windowMap { log.Warn(rs.GetMasterVersion(), path) @@ -35,16 +39,27 @@ func NewRepoStatusWindow(path string) *RepoStatus { return windowMap[path] } + var realpath string + 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(goSrcDir, path, ".git/config") + // allow arbitrary paths, otherwise, assume the repo is in ~/go/src + if strings.HasPrefix(path, "/") { + realpath = path + } else if strings.HasPrefix(path, "~") { + // TODO: example this to homedir + tmp := strings.TrimPrefix(path, "~") + realpath = filepath.Join(homeDir, tmp) + } else { + realpath = filepath.Join(goSrcDir, path) + } + + filename := filepath.Join(realpath, ".git/config") _, err = os.Open(filename) if err != nil { @@ -60,18 +75,34 @@ func NewRepoStatusWindow(path string) *RepoStatus { rs.window = gadgets.RawBasicWindow("GO Repo Details " + path) rs.window.Horizontal() rs.window.Make() + basebox := rs.window.Box() + group := basebox.NewGroup("stuff") + primarybox := group.Box() + primarybox.Horizontal() + box2 := group.Box() rs.ready = true rs.window.Custom = func() { rs.Hide() log.Warn("repostatus user closed the window()") } - rs.draw() + + // display the status of the git repository + rs.drawGitStatus(primarybox) + + // display the git branches and options + rs.makeBranchesBox(primarybox) + + // show standard git commit and merge controls + rs.drawGitCommands(primarybox) // save ~/go/src & the whole path strings rs.path.SetValue(path) rs.goSrcPath.SetValue(goSrcDir) rs.realPath.SetValue(realpath) + // add all the tags + rs.makeTagBox(box2) + rs.readGitConfig() rs.readOnly.SetValue("true") @@ -86,7 +117,3 @@ func NewRepoStatusWindow(path string) *RepoStatus { windowMap[path] = rs return rs } - -func init() { - windowMap = make(map[string]*RepoStatus) -} |
