From 07e0fdc43724433e18f2fb469b829a7b0b125800 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 7 Jan 2025 18:18:38 -0600 Subject: [PATCH] rm old code --- git.go | 9 ++-- unix.go | 162 +------------------------------------------------------- 2 files changed, 6 insertions(+), 165 deletions(-) diff --git a/git.go b/git.go index 3b66d9d..b0963c7 100644 --- a/git.go +++ b/git.go @@ -44,6 +44,7 @@ func (rs *RepoStatus) Path() string { return rs.realPath.String() } +/* func (rs *RepoStatus) checkoutBranch(level string, branch string) { if rs.CheckDirty() { log.Log(REPO, "checkoutBranch() checkDirty() == true for repo", rs.realPath.String(), "looking for branch:", branch) @@ -66,6 +67,7 @@ func (rs *RepoStatus) checkoutBranch(level string, branch string) { default: } } +*/ func (rs *RepoStatus) GitState() string { return rs.gitState.String() @@ -126,7 +128,7 @@ func (rs *RepoStatus) displayCurrentBranchName() string { // stores the current branch name func (rs *RepoStatus) checkCurrentBranchName() string { currentname := rs.currentBranch.String() - out := run(rs.realPath.String(), "git", "branch --show-current") + out := rs.pb.GetCurrentBranchName() if currentname == out { // nothing changed return currentname @@ -189,10 +191,7 @@ func (rs *RepoStatus) checkCurrentBranchVersion() string { // this should get the most recent tag func (rs *RepoStatus) setLastTagVersion() { - hash := run(rs.realPath.String(), "git", "rev-list --tags --max-count=1") - log.Log(REPO, "getLastTagVersion()", hash) - - name, _ := rs.gitDescribeByHash(hash) + name := rs.pb.GetLastTagVersion() rs.lasttag.SetText(name) return } diff --git a/unix.go b/unix.go index f91fd02..dbbaed0 100644 --- a/unix.go +++ b/unix.go @@ -14,6 +14,7 @@ import ( "go.wit.com/log" ) +/* func run(path string, thing string, cmdline string) string { parts := strings.Split(cmdline, " ") // Create the command @@ -37,6 +38,7 @@ func run(path string, thing string, cmdline string) string { log.Log(INFO, "run()", path, thing, cmdline, "=", tmp) return tmp } +*/ // goes in one directory so it gets remote branch names func listFiles(directory string) []string { @@ -64,28 +66,6 @@ func listFiles(directory string) []string { return files } -/* -// string handling examples that might be helpful for normalizeInt() -isAlpha := regexp.MustCompile(`^[A-Za-z]+$`).MatchString - -for _, username := range []string{"userone", "user2", "user-three"} { - if !isAlpha(username) { - log.Log(GUI, "%q is not valid\n", username) - } -} - -const alpha = "abcdefghijklmnopqrstuvwxyz" - -func alphaOnly(s string) bool { - for _, char := range s { - if !strings.Contains(alpha, strings.ToLower(string(char))) { - return false - } - } - return true -} -*/ - func normalizeVersion(s string) string { // reg, err := regexp.Compile("[^a-zA-Z0-9]+") parts := strings.Split(s, "-") @@ -177,47 +157,6 @@ func Exists(file string) bool { return true } -/* -func readFileToString(filename string) (string, error) { - data, err := ioutil.ReadFile(filename) - if err != nil { - return "", err - } - return strings.TrimSpace(string(data)), nil -} - -// converts a git for-each-ref date. "Wed Feb 7 10:13:38 2024 -0600" -func getGitDateStamp(gitdefault string) (time.Time, string, string) { - // now := time.Now().Format("Wed Feb 7 10:13:38 2024 -0600") - const gitLayout = "Mon Jan 2 15:04:05 2006 -0700" - tagTime, err := time.Parse(gitLayout, gitdefault) - if err != nil { - log.Warn("GOT THIS IN PARSE AAA." + gitdefault + ".AAA") - log.Warn(err) - return time.Now(), "Feb 1 12:34:56 1978 -0600", "" - } - return tagTime, gitdefault, getDurationStamp(tagTime) -} -func getRawDateStamp(raw string) (time.Time, string, string) { - parts := strings.Split(raw, " ") - if len(parts) == 0 { - // raw was blank here - // return "Jan 4 1977", "40y" // eh, why not. it'll be easy to grep for this - return time.Now(), "Jan 4 1977", "40y" // eh, why not. it'll be easy to grep for this - } - i, err := strconv.ParseInt(parts[0], 10, 64) // base 10 string, return int64 - if err != nil { - log.Warn("Error converting timestamp:", raw) - log.Warn("Error converting timestamp err =", err) - return time.Now(), "", "" - } - - // Parse the Unix timestamp into a time.Time object - gitTagDate := time.Unix(i, 0) - return gitTagDate, gitTagDate.UTC().Format("2006/01/02 15:04:05 UTC"), getDurationStamp(gitTagDate) -} -*/ - func getDurationStamp(t time.Time) string { // Get the current time @@ -269,78 +208,6 @@ func (rs *RepoStatus) XtermWait(cmdline string) { shell.XtermCmdWait(rs.Path(), []string{cmdline}) } -/* -func (rs *RepoStatus) XtermNohup(args []string) { - var argsX = []string{"xterm", "-geometry", "120x40"} - argsX = append(argsX, "-e", "bash", "-c") - argsX = append(argsX, args...) - log.Info("xterm cmd=", argsX) - // set less to not exit on small diff's - os.Setenv("LESS", "-+F -+X -R") - cmd := exec.Command("nohup", argsX...) - path := rs.realPath.String() - cmd.Dir = path - log.Info("path =", path) - log.Info("cmd =", strings.Join(args, " ")) - if err := cmd.Run(); err != nil { - log.Info("xterm.Run() failed") - log.Info("path =", path) - log.Info("cmd =", argsX) - } else { - log.Info("xterm.Run() worked") - log.Info("path =", path) - log.Info("cmd =", argsX) - } -} -*/ - -/* -func (rs *RepoStatus) Xterm(args []string) { - var argsX = []string{"-geometry", "120x40"} - argsX = append(argsX, "-e", "bash", "-c") - argsX = append(argsX, args...) - log.Info("xterm cmd=", argsX) - // set less to not exit on small diff's - os.Setenv("LESS", "-+F -+X -R") - cmd := exec.Command("xterm", argsX...) - path := rs.realPath.String() - cmd.Dir = path - if err := cmd.Run(); err != nil { - log.Info("xterm.Run() failed") - log.Info("path =", path) - log.Info("cmd = xterm", argsX) - } else { - log.Info("xterm.Run() worked") - log.Info("path =", path) - log.Info("cmd = xterm", argsX) - } -} -*/ - -/* -func (rs *RepoStatus) XtermHold(args []string) { - var argsX = []string{"-hold", "-geometry", "120x40"} - tmp := strings.Join(args, " ") + ";bash" - argsX = append(argsX, "-e", "bash", "-c", tmp) - argsX = append(argsX, args...) - log.Info("xterm cmd=", argsX) - // set less to not exit on small diff's - os.Setenv("LESS", "-+F -+X -R") - cmd := exec.Command("xterm", argsX...) - path := rs.realPath.String() - cmd.Dir = path - if err := cmd.Run(); err != nil { - log.Info("xterm.Run() failed") - log.Info("path =", path) - log.Info("cmd = xterm", argsX) - } else { - log.Info("xterm.Run() worked") - log.Info("path =", path) - log.Info("cmd = xterm", argsX) - } -} -*/ - func (rs *RepoStatus) XtermBash(args []string) { var argsX = []string{"-geometry", "120x40"} tmp := strings.Join(args, " ") + ";bash" @@ -375,28 +242,3 @@ func (rs *RepoStatus) DoAll(all [][]string) bool { } return true } - -/* -func ScanGitDirectories(srcDir string) []string { - var all []string - err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error { - if err != nil { - log.Log(REPOWARN, "Error accessing path:", path, err) - return nil - } - - // Check if the path is a directory and has a .git subdirectory - if info.IsDir() && IsGitDir(path) { - all = append(all, path) - } - - return nil - }) - - if err != nil { - log.Log(REPOWARN, "Error walking the path:", srcDir, err) - } - - return all -} -*/