diff options
| author | Jeff Carr <[email protected]> | 2024-02-11 06:32:48 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-11 06:32:48 -0600 |
| commit | e4e12ae90dd2f9775b1d45c1d083a4e44817a655 (patch) | |
| tree | 8e368c2e9fad9a6f0d2e7543fc7bf2f208a85bf0 /addRepo.go | |
| parent | e78fd84d74158731e5cb2ae32ffc1699e5e1cfba (diff) | |
specify repo on command line works
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'addRepo.go')
| -rw-r--r-- | addRepo.go | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/addRepo.go b/addRepo.go new file mode 100644 index 0000000..1a25dc9 --- /dev/null +++ b/addRepo.go @@ -0,0 +1,78 @@ +// This is a simple example +package main + +import ( + "strings" + + "go.wit.com/lib/gadgets" + "go.wit.com/lib/gui/repostatus" + "go.wit.com/log" +) + +func RemoveFirstElement(slice []string) (string, []string) { + if len(slice) == 0 { + return "", slice // Return the original slice if it's empty + } + return slice[0], slice[1:] // Return the slice without the first element +} + +// homeDir, _ := os.UserHomeDir() + +func (c *controlBox) addRepo(path string) { + path = strings.Trim(path, "/") // trim any extranous '/' chars put in the config file by the user + if path == "" { + log.Warn("addRepo() got empty path", path) + return + } + + if repostatus.VerifyLocalGoRepo(path) { + log.Verbose("path actually exists", path) + } else { + log.Warn("repostatus.VerifyLocalGoRepo() failed for for", path) + return + } + + c.pathL = gadgets.NewOneLiner(c.grid, "path") + c.pathL.SetText(path) + c.grid.NextRow() + + c.lastTag = gadgets.NewOneLiner(c.grid, "lastTag") + c.lastTag.SetText(path) + c.grid.NextRow() + + c.dirtyL = gadgets.NewOneLiner(c.grid, "dirty") + c.grid.NextRow() + + c.currentL = gadgets.NewOneLiner(c.grid, "current") + c.grid.NextRow() + + c.status = repostatus.NewRepoStatusWindow(path) + c.status.SetMainWorkingName("master") + c.status.SetDevelWorkingName("devel") + c.status.SetUserWorkingName("jcarr") + c.status.Update() + + + cbname := c.status.GetCurrentBranchName() + cbversion := c.status.GetCurrentBranchVersion() + debversion := strings.TrimPrefix(cbversion, "v") + + if c.status.CheckDirty() { + c.dirtyL.SetText("true") + debversion = debversion + "-dirty" + } else { + c.dirtyL.SetText("false") + } + + c.Version.SetText(debversion) + + lasttag := c.status.GetLastTagVersion() + c.lastTag.SetText(lasttag) + c.currentL.SetText(cbname + " " + cbversion) + + if c.status.Changed() { + log.Warn("should scan here") + } + + return +} |
