summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-22 21:11:59 -0600
committerJeff Carr <[email protected]>2024-02-22 21:11:59 -0600
commite0bda97e5f522e3bf54c423290667763e9f60775 (patch)
treeef503e1de519cf458fc58b093a70792942ad0150
parent0bc14b614576b7b5753b72015f7e0a9b3d64c0e3 (diff)
common repolist codev0.20.0
-rw-r--r--initRepoList.go47
1 files changed, 2 insertions, 45 deletions
diff --git a/initRepoList.go b/initRepoList.go
index befe28c..0a3b24c 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/autotypist")
- 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/autotypist")
if args.OnlyMe {
log.Info("not scanning everything")
@@ -42,29 +21,7 @@ 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 = repolist.RemoveFirstElement(parts)
- master, parts = repolist.RemoveFirstElement(parts)
- devel, parts = repolist.RemoveFirstElement(parts)
- user, parts = repolist.RemoveFirstElement(parts)
- // path, master, devel, user := strings.Split(line, " ")
- return path, master, devel, user
-}