diff options
| author | Jeff Carr <[email protected]> | 2024-02-22 21:10:33 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-22 21:10:33 -0600 |
| commit | f68e76b9142af35fb0cb8ff09ac330a2f7ac2f17 (patch) | |
| tree | 7fa30ce520434bce3cca9969c81145ffcf89ecfb /initRepoList.go | |
| parent | 197e2a4601dd5f6a232e07618dce41d718f6bb52 (diff) | |
move to common repolist code
Diffstat (limited to 'initRepoList.go')
| -rw-r--r-- | initRepoList.go | 46 |
1 files changed, 2 insertions, 44 deletions
diff --git a/initRepoList.go b/initRepoList.go index 9cf08b5..6d81149 100644 --- a/initRepoList.go +++ b/initRepoList.go @@ -3,35 +3,14 @@ package main // this initializes the repos import ( - "io/ioutil" - "os" - "os/user" - "path/filepath" "strings" - "go.wit.com/lib/gui/repolist" "go.wit.com/lib/gui/repostatus" "go.wit.com/log" ) func (r *repoWindow) initRepoList() { - usr, _ := user.Current() - - repos := parsecfg("~/.config/guireleaser") - for _, line := range repos { - log.Verbose("repo =", line) - path, mbranch, dbranch, ubranch := splitLine(line) - if mbranch == "" { - mbranch = "master" - } - if dbranch == "" { - dbranch = "devel" - } - if ubranch == "" { - ubranch = usr.Username - } - r.View.AddRepo(path, mbranch, dbranch, ubranch) - } + r.View.InitRepoList("~/.config/guireleaser") log.Info("scanning everything in ~/go/src") for i, path := range repostatus.ListGitDirectories() { @@ -39,27 +18,6 @@ func (r *repoWindow) initRepoList() { path = strings.TrimPrefix(path, me.goSrcPwd.String()) path = strings.Trim(path, "/") log.Info("addRepo()", i, path) - r.View.AddRepo(path, "master", "devel", usr.Username) + r.View.NewRepo(path) } } - -func parsecfg(f string) []string { - homeDir, _ := os.UserHomeDir() - cfgfile := filepath.Join(homeDir, f) - content, _ := ioutil.ReadFile(cfgfile) - out := string(content) - out = strings.TrimSpace(out) - lines := strings.Split(out, "\n") - return lines -} - -// returns path, master branch name, devel branch name, user branch name -func splitLine(line string) (string, string, string, string) { - var path, master, devel, user string - parts := strings.Split(line, " ") - path, parts = shell.RemoveFirstElement(parts) - master, parts = shell.RemoveFirstElement(parts) - devel, parts = shell.RemoveFirstElement(parts) - user, parts = shell.RemoveFirstElement(parts) - return path, master, devel, user -} |
