summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-14 15:17:42 -0600
committerJeff Carr <[email protected]>2024-02-14 15:17:42 -0600
commitf8c07556f9b93745b4165e2b9e419b662d95c3b9 (patch)
tree04d74c6a266a2a2aabc9479894bfbdc28383bd9d
parent020a4eb206239a35c89bc1de1fc0402e2a5d6132 (diff)
fix the hacky version listv0.20.7v0.20.6
-rw-r--r--dumpVersions.go55
-rw-r--r--listWindow.go43
2 files changed, 56 insertions, 42 deletions
diff --git a/dumpVersions.go b/dumpVersions.go
new file mode 100644
index 0000000..1a19ba4
--- /dev/null
+++ b/dumpVersions.go
@@ -0,0 +1,55 @@
+package gowit
+
+import (
+ "fmt"
+ "os"
+ "strconv"
+ "strings"
+ "time"
+
+ "go.wit.com/log"
+ "go.wit.com/lib/gui/repostatus"
+)
+
+func dumpVersions() {
+ f, _ := os.OpenFile("/tmp/go.wit.com.versions", os.O_WRONLY|os.O_CREATE, 0600)
+ defer f.Close()
+ for _, sec := range allsections {
+ for _, wrepo := range sec.witRepos {
+ var r *repostatus.RepoStatus
+ r = repostatus.FindPath(wrepo.path.String())
+ if r == nil {
+ log.Info("repo not scanned for some reason", wrepo.path.String())
+ continue
+ }
+ lastTag := r.GetLastTagVersion()
+ _, out := r.RunCmd([]string{"git", "log", "-1", "--format=%at", lastTag})
+ out = strings.TrimSpace(out)
+
+ // Convert the string to an integer
+ gitTagTimestampInt, err := strconv.ParseInt(out, 10, 64)
+ if err != nil {
+ fmt.Println("Error converting timestamp:", err)
+ return
+ }
+
+ // Parse the Unix timestamp into a time.Time object
+ gitTagDate := time.Unix(gitTagTimestampInt, 0)
+
+ // Get the current time
+ currentTime := time.Now()
+
+ // Calculate the duration between the git tag date and the current time
+ duration := currentTime.Sub(gitTagDate)
+
+ // s := fmt.Sprint(duration)
+ // fmt.Println("Duration since the git tag date:", s)
+
+ // fmt.Println("Default formatting:", duration.String())
+ // fmt.Println("Custom formatting:", formatDuration(duration))
+ log.Warn("found:", wrepo.path.String(), lastTag, out, formatDuration(duration))
+ fmt.Fprintln(f, wrepo.path.String(), lastTag, out)
+ //wrepo.path.Show()
+ }
+ }
+}
diff --git a/listWindow.go b/listWindow.go
index 325824d..ec69783 100644
--- a/listWindow.go
+++ b/listWindow.go
@@ -75,7 +75,7 @@ func ListWindow() *gadgets.BasicWindow {
box := lw.Box()
group := box.NewGroup("list")
group.NewButton("make new go version list", func() {
- // dumpVersions()
+ dumpVersions()
})
var lines []string
@@ -265,47 +265,6 @@ func dumpURL(url string) []string {
return strings.Split(string(bodyBytes), "\n")
}
-/*
-func dumpVersions() {
- f, _ := os.OpenFile("/tmp/go.wit.com.versions", os.O_WRONLY|os.O_CREATE, 0600)
- defer f.Close()
- for _, sec := range allsections {
- for _, wrepo := range sec.witRepos {
- r, ok := me.allrepos[wrepo.path.String()]
- if ok {
- _, out := r.status.RunCmd([]string{"git", "log", "-1", "--format=%at", r.lastTag.String()})
- out = strings.TrimSpace(out)
-
- // Convert the string to an integer
- gitTagTimestampInt, err := strconv.ParseInt(out, 10, 64)
- if err != nil {
- fmt.Println("Error converting timestamp:", err)
- return
- }
-
- // Parse the Unix timestamp into a time.Time object
- gitTagDate := time.Unix(gitTagTimestampInt, 0)
-
- // Get the current time
- currentTime := time.Now()
-
- // Calculate the duration between the git tag date and the current time
- duration := currentTime.Sub(gitTagDate)
-
- // s := fmt.Sprint(duration)
- // fmt.Println("Duration since the git tag date:", s)
-
- // fmt.Println("Default formatting:", duration.String())
- // fmt.Println("Custom formatting:", formatDuration(duration))
- log.Warn("found:", wrepo.path.String(), r.lastTag.String(), out, formatDuration(duration))
- fmt.Fprintln(f, wrepo.path.String(), r.lastTag.String(), out)
- }
- //wrepo.path.Show()
- }
- }
-}
-*/
-
func formatDuration(d time.Duration) string {
seconds := int(d.Seconds()) % 60
minutes := int(d.Minutes()) % 60