2024-01-09 15:34:53 -06:00
|
|
|
package repostatus
|
|
|
|
|
2024-01-18 00:57:43 -06:00
|
|
|
import (
|
|
|
|
"errors"
|
2024-02-12 06:23:31 -06:00
|
|
|
"fmt"
|
2024-01-23 22:47:39 -06:00
|
|
|
"io/ioutil"
|
2024-01-09 15:34:53 -06:00
|
|
|
"os"
|
|
|
|
"os/exec"
|
2024-01-13 00:43:26 -06:00
|
|
|
"os/user"
|
|
|
|
"path/filepath"
|
2024-01-18 00:57:43 -06:00
|
|
|
"regexp"
|
2024-02-12 06:23:31 -06:00
|
|
|
"strconv"
|
2024-01-18 00:57:43 -06:00
|
|
|
"strings"
|
2024-02-12 06:23:31 -06:00
|
|
|
"time"
|
2024-01-09 15:34:53 -06:00
|
|
|
|
2024-02-12 18:16:03 -06:00
|
|
|
"go.wit.com/lib/gui/shell"
|
2024-01-09 15:34:53 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
|
|
|
func run(path string, thing string, cmdline string) string {
|
|
|
|
parts := strings.Split(cmdline, " ")
|
|
|
|
// Create the command
|
|
|
|
cmd := exec.Command(thing, parts...)
|
|
|
|
|
|
|
|
// Set the working directory
|
2024-01-23 15:20:54 -06:00
|
|
|
cmd.Dir = path
|
2024-01-09 15:34:53 -06:00
|
|
|
|
|
|
|
// Execute the command
|
|
|
|
output, err := cmd.CombinedOutput()
|
2024-01-23 10:52:17 -06:00
|
|
|
tmp := string(output)
|
|
|
|
tmp = strings.TrimSpace(tmp)
|
|
|
|
|
2024-01-09 15:34:53 -06:00
|
|
|
if err != nil {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(WARN, "run()", path, thing, cmdline, "=", tmp)
|
2024-01-09 15:34:53 -06:00
|
|
|
log.Error(err, "cmd error'd out", parts)
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
// Print the output
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "run()", path, thing, cmdline, "=", tmp)
|
2024-01-09 15:34:53 -06:00
|
|
|
return tmp
|
|
|
|
}
|
|
|
|
|
2024-01-11 15:56:50 -06:00
|
|
|
// goes in one directory so it gets remote branch names
|
2024-01-09 15:34:53 -06:00
|
|
|
func listFiles(directory string) []string {
|
|
|
|
var files []string
|
|
|
|
fileInfo, err := os.ReadDir(directory)
|
|
|
|
if err != nil {
|
|
|
|
log.Error(err)
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, file := range fileInfo {
|
2024-01-11 15:56:50 -06:00
|
|
|
if file.IsDir() {
|
|
|
|
dirname := file.Name()
|
|
|
|
newdir, _ := os.ReadDir(directory + "/" + dirname)
|
|
|
|
for _, file := range newdir {
|
2024-01-18 00:57:43 -06:00
|
|
|
if !file.IsDir() {
|
|
|
|
files = append(files, dirname+"/"+file.Name())
|
2024-01-11 15:56:50 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2024-01-09 15:34:53 -06:00
|
|
|
files = append(files, file.Name())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return files
|
|
|
|
}
|
2024-01-09 19:35:05 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
// 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, "-")
|
2024-01-18 00:57:43 -06:00
|
|
|
if len(parts) == 0 {
|
|
|
|
return ""
|
|
|
|
}
|
2024-01-09 19:35:05 -06:00
|
|
|
reg, err := regexp.Compile("[^0-9.]+")
|
|
|
|
if err != nil {
|
|
|
|
log.Log(WARN, "normalizeVersion() regexp.Compile() ERROR =", err)
|
|
|
|
return parts[0]
|
|
|
|
}
|
|
|
|
clean := reg.ReplaceAllString(parts[0], "")
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "normalizeVersion() s =", clean)
|
2024-01-09 19:35:05 -06:00
|
|
|
return clean
|
|
|
|
}
|
2024-01-10 00:15:27 -06:00
|
|
|
|
|
|
|
func splitVersion(version string) (a, b, c string) {
|
|
|
|
tmp := normalizeVersion(version)
|
|
|
|
parts := strings.Split(tmp, ".")
|
|
|
|
switch len(parts) {
|
|
|
|
case 1:
|
|
|
|
return parts[0], "", ""
|
|
|
|
case 2:
|
|
|
|
return parts[0], parts[1], ""
|
|
|
|
default:
|
|
|
|
return parts[0], parts[1], parts[2]
|
|
|
|
}
|
|
|
|
}
|
2024-01-10 18:18:01 -06:00
|
|
|
|
2024-02-15 22:50:50 -06:00
|
|
|
func (rs *RepoStatus) RunCmdEcho(parts []string) (error, string) {
|
|
|
|
log.Info("RunCmdEcho()", parts)
|
|
|
|
return rs.RunCmd(parts)
|
|
|
|
}
|
|
|
|
|
2024-01-24 16:24:58 -06:00
|
|
|
func (rs *RepoStatus) RunCmd(parts []string) (error, string) {
|
|
|
|
path := rs.realPath.String()
|
2024-02-12 18:16:03 -06:00
|
|
|
err, _, output := shell.RunCmd(path, parts)
|
2024-01-24 16:24:58 -06:00
|
|
|
if err != nil {
|
|
|
|
log.Log(WARN, "cmd:", parts)
|
|
|
|
log.Log(WARN, "ouptput:", output)
|
|
|
|
log.Log(WARN, "failed with error:", err)
|
|
|
|
}
|
|
|
|
return err, output
|
|
|
|
}
|
|
|
|
|
2024-01-15 17:03:06 -06:00
|
|
|
// temp hack. fix this
|
2024-01-11 15:56:50 -06:00
|
|
|
func runCmd(path string, parts []string) (error, bool, string) {
|
2024-02-12 18:16:03 -06:00
|
|
|
return shell.RunCmd(path, parts)
|
2024-01-15 08:12:04 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func RunCmd(workingpath string, parts []string) (error, bool, string) {
|
2024-01-10 18:18:01 -06:00
|
|
|
if len(parts) == 0 {
|
|
|
|
log.Warn("command line was empty")
|
2024-01-11 15:56:50 -06:00
|
|
|
return errors.New("empty"), false, ""
|
2024-01-10 18:18:01 -06:00
|
|
|
}
|
|
|
|
if parts[0] == "" {
|
|
|
|
log.Warn("command line was empty")
|
2024-01-11 15:56:50 -06:00
|
|
|
return errors.New("empty"), false, ""
|
2024-01-10 18:18:01 -06:00
|
|
|
}
|
|
|
|
thing := parts[0]
|
|
|
|
parts = parts[1:]
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "working path =", workingpath, "thing =", thing, "cmdline =", parts)
|
2024-01-10 18:18:01 -06:00
|
|
|
|
|
|
|
// Create the command
|
|
|
|
cmd := exec.Command(thing, parts...)
|
|
|
|
|
|
|
|
// Set the working directory
|
2024-01-15 08:12:04 -06:00
|
|
|
cmd.Dir = workingpath
|
2024-01-10 18:18:01 -06:00
|
|
|
|
|
|
|
// Execute the command
|
|
|
|
output, err := cmd.CombinedOutput()
|
|
|
|
if err != nil {
|
2024-01-23 10:52:17 -06:00
|
|
|
if thing == "git" {
|
|
|
|
log.Log(INFO, "git ERROR. maybe okay", workingpath, "thing =", thing, "cmdline =", parts)
|
|
|
|
log.Log(INFO, "git ERROR. maybe okay err =", err)
|
|
|
|
if err.Error() == "exit status 1" {
|
|
|
|
log.Log(INFO, "git ERROR. normal exit status 1")
|
|
|
|
if parts[0] == "diff-index" {
|
|
|
|
log.Log(INFO, "git normal diff-index when repo dirty")
|
|
|
|
return nil, false, "git diff-index exit status 1"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Log(WARN, "ERROR working path =", workingpath, "thing =", thing, "cmdline =", parts)
|
|
|
|
log.Log(WARN, "ERROR working path =", workingpath, "thing =", thing, "cmdline =", parts)
|
|
|
|
log.Log(WARN, "ERROR working path =", workingpath, "thing =", thing, "cmdline =", parts)
|
2024-01-10 18:18:01 -06:00
|
|
|
log.Error(err)
|
2024-01-18 05:01:54 -06:00
|
|
|
log.Warn("output was", string(output))
|
2024-01-10 18:18:01 -06:00
|
|
|
log.Warn("cmd exited with error", err)
|
2024-01-23 10:52:17 -06:00
|
|
|
// panic("fucknuts")
|
2024-01-11 15:56:50 -06:00
|
|
|
return err, false, string(output)
|
2024-01-24 16:24:58 -06:00
|
|
|
|
2024-03-02 17:52:45 -06:00
|
|
|
/* todo: see if there is a way to get the exit value
|
2024-01-24 16:24:58 -06:00
|
|
|
// The command failed (non-zero exit status)
|
|
|
|
if exitErr, ok := err.(*exec.ExitError); ok {
|
|
|
|
// Assert that it is an exec.ExitError and get the exit code
|
|
|
|
if status, ok := exitErr.Sys().(syscall.WaitStatus); ok {
|
|
|
|
log.Warn("Exit Status: %d\n", status.ExitStatus())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
log.Warn("cmd.Run() failed with %s\n", err)
|
|
|
|
}
|
2024-03-02 17:52:45 -06:00
|
|
|
*/
|
2024-01-10 18:18:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
tmp := string(output)
|
|
|
|
tmp = strings.TrimSpace(tmp)
|
|
|
|
|
|
|
|
// Print the output
|
2024-01-11 15:56:50 -06:00
|
|
|
return nil, true, tmp
|
2024-01-10 18:18:01 -06:00
|
|
|
}
|
2024-01-13 00:43:26 -06:00
|
|
|
|
|
|
|
// Set the path to the package
|
|
|
|
func getfiles(pathToPackage string) {
|
|
|
|
// List files in the directory
|
|
|
|
err := filepath.Walk(pathToPackage, nil) // compiles but crashes
|
|
|
|
if err == nil {
|
2024-01-23 10:52:17 -06:00
|
|
|
log.Log(INFO, "directory ok", pathToPackage)
|
2024-01-13 00:43:26 -06:00
|
|
|
} else {
|
|
|
|
log.Warn("directory wrong", pathToPackage)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func IsDirectory(path string) bool {
|
|
|
|
info, err := os.Stat(path)
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return info.IsDir()
|
|
|
|
}
|
|
|
|
|
2024-02-06 04:02:46 -06:00
|
|
|
func (rs *RepoStatus) Exists(filename string) bool {
|
|
|
|
usr, err := user.Current()
|
|
|
|
if err != nil {
|
|
|
|
log.Error(err, "Exists() error: could not determine what your username is")
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
testf := filepath.Join(usr.HomeDir, "go/src/", rs.String(), filename)
|
|
|
|
if Exists(testf) {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2024-02-22 17:19:29 -06:00
|
|
|
func (rs *RepoStatus) mtime(filename string) (time.Time, error) {
|
|
|
|
pathf := filepath.Join(rs.Path(), filename)
|
|
|
|
statf, err := os.Stat(pathf)
|
|
|
|
if err == nil {
|
|
|
|
return statf.ModTime(), nil
|
|
|
|
}
|
|
|
|
log.Log(REPOWARN, "mtime() error", pathf, err)
|
|
|
|
return time.Now(), err
|
|
|
|
}
|
|
|
|
|
2024-01-30 16:48:57 -06:00
|
|
|
// returns true if the file exists
|
|
|
|
func Exists(file string) bool {
|
|
|
|
_, err := os.Stat(file)
|
|
|
|
if err != nil {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-01-23 22:47:39 -06:00
|
|
|
func readFileToString(filename string) (string, error) {
|
|
|
|
data, err := ioutil.ReadFile(filename)
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
return strings.TrimSpace(string(data)), nil
|
|
|
|
}
|
2024-02-12 06:23:31 -06:00
|
|
|
|
2024-02-16 01:22:37 -06:00
|
|
|
// 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 {
|
2024-02-16 11:41:29 -06:00
|
|
|
log.Warn("GOT THIS IN PARSE AAA." + gitdefault + ".AAA")
|
2024-02-16 01:22:37 -06:00
|
|
|
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) {
|
2024-02-12 06:23:31 -06:00
|
|
|
parts := strings.Split(raw, " ")
|
|
|
|
if len(parts) == 0 {
|
|
|
|
// raw was blank here
|
2024-02-15 22:50:50 -06:00
|
|
|
// 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
|
2024-02-12 06:23:31 -06:00
|
|
|
}
|
|
|
|
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)
|
2024-02-15 22:50:50 -06:00
|
|
|
return time.Now(), "", ""
|
2024-02-12 06:23:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// Parse the Unix timestamp into a time.Time object
|
|
|
|
gitTagDate := time.Unix(i, 0)
|
2024-02-15 22:50:50 -06:00
|
|
|
return gitTagDate, gitTagDate.UTC().Format("2006/01/02 15:04:05 UTC"), getDurationStamp(gitTagDate)
|
2024-02-12 06:23:31 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func getDurationStamp(t time.Time) string {
|
|
|
|
|
|
|
|
// Get the current time
|
|
|
|
currentTime := time.Now()
|
|
|
|
|
|
|
|
// Calculate the duration between t current time
|
|
|
|
duration := currentTime.Sub(t)
|
|
|
|
|
|
|
|
return formatDuration(duration)
|
|
|
|
}
|
|
|
|
|
|
|
|
func formatDuration(d time.Duration) string {
|
|
|
|
seconds := int(d.Seconds()) % 60
|
|
|
|
minutes := int(d.Minutes()) % 60
|
|
|
|
hours := int(d.Hours()) % 24
|
|
|
|
days := int(d.Hours()) / 24
|
2024-02-16 11:41:29 -06:00
|
|
|
years := int(d.Hours()) / (24 * 365)
|
2024-02-12 06:23:31 -06:00
|
|
|
|
|
|
|
result := ""
|
2024-02-16 11:41:29 -06:00
|
|
|
if years > 0 {
|
|
|
|
result += fmt.Sprintf("%dy ", years)
|
|
|
|
return result
|
|
|
|
}
|
2024-02-12 06:23:31 -06:00
|
|
|
if days > 0 {
|
|
|
|
result += fmt.Sprintf("%dd ", days)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
if hours > 0 {
|
|
|
|
result += fmt.Sprintf("%dh ", hours)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
if minutes > 0 {
|
|
|
|
result += fmt.Sprintf("%dm ", minutes)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
if seconds > 0 {
|
|
|
|
result += fmt.Sprintf("%ds", seconds)
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
2024-02-12 15:27:40 -06:00
|
|
|
|
2024-02-15 22:50:50 -06:00
|
|
|
func (rs *RepoStatus) XtermNohup(cmdline string) {
|
|
|
|
shell.XtermCmd(rs.Path(), []string{cmdline})
|
|
|
|
}
|
|
|
|
func (rs *RepoStatus) Xterm(cmdline string) {
|
|
|
|
shell.XtermCmd(rs.Path(), []string{cmdline})
|
|
|
|
}
|
|
|
|
func (rs *RepoStatus) XtermWait(cmdline string) {
|
|
|
|
shell.XtermCmdWait(rs.Path(), []string{cmdline})
|
|
|
|
}
|
2024-02-16 11:41:29 -06:00
|
|
|
|
2024-02-15 22:50:50 -06:00
|
|
|
/*
|
2024-02-12 15:27:40 -06:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
2024-02-15 22:50:50 -06:00
|
|
|
*/
|
2024-02-12 15:27:40 -06:00
|
|
|
|
2024-02-15 22:50:50 -06:00
|
|
|
/*
|
2024-02-12 15:27:40 -06:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
2024-02-15 22:50:50 -06:00
|
|
|
*/
|
2024-02-12 21:50:54 -06:00
|
|
|
|
2024-02-15 22:50:50 -06:00
|
|
|
/*
|
2024-02-12 21:50:54 -06:00
|
|
|
func (rs *RepoStatus) XtermHold(args []string) {
|
|
|
|
var argsX = []string{"-hold", "-geometry", "120x40"}
|
2024-02-15 22:50:50 -06:00
|
|
|
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"
|
|
|
|
argsX = append(argsX, "-e", "bash", "-c", tmp)
|
2024-02-12 21:50:54 -06:00
|
|
|
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 {
|
2024-02-16 21:20:52 -06:00
|
|
|
log.Log(WARN, "xterm.Run() failed")
|
|
|
|
log.Log(WARN, "path =", path)
|
|
|
|
log.Log(WARN, "cmd = xterm", argsX)
|
2024-02-12 21:50:54 -06:00
|
|
|
} else {
|
2024-02-16 21:20:52 -06:00
|
|
|
log.Log(WARN, "xterm.Run() worked")
|
|
|
|
log.Log(WARN, "path =", path)
|
|
|
|
log.Log(WARN, "cmd = xterm", argsX)
|
2024-02-12 21:50:54 -06:00
|
|
|
}
|
|
|
|
}
|
2024-02-14 00:09:58 -06:00
|
|
|
|
|
|
|
func (rs *RepoStatus) DoAll(all [][]string) bool {
|
|
|
|
for _, cmd := range all {
|
2024-02-16 21:20:52 -06:00
|
|
|
log.Log(WARN, "doAll() RUNNING: cmd =", cmd)
|
2024-02-14 00:09:58 -06:00
|
|
|
err, out := rs.RunCmd(cmd)
|
|
|
|
if err != nil {
|
2024-02-16 21:20:52 -06:00
|
|
|
log.Log(WARN, "doAll() err =", err)
|
|
|
|
log.Log(WARN, "doAll() out =", out)
|
2024-02-14 00:09:58 -06:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
2024-03-07 19:31:52 -06:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|