2024-02-14 15:17:42 -06:00
|
|
|
package gowit
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
2024-02-18 15:09:19 -06:00
|
|
|
"go.wit.com/lib/gui/repolist"
|
2024-02-14 15:17:42 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-02-18 15:09:19 -06:00
|
|
|
func dumpVersions(view *repolist.RepoList) {
|
2024-02-14 15:17:42 -06:00
|
|
|
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 {
|
2024-02-18 15:09:19 -06:00
|
|
|
var r *repolist.Repo
|
|
|
|
r = view.FindRepo(wrepo.path.String())
|
2024-02-14 15:17:42 -06:00
|
|
|
if r == nil {
|
|
|
|
log.Info("repo not scanned for some reason", wrepo.path.String())
|
|
|
|
continue
|
|
|
|
}
|
2024-02-18 15:09:19 -06:00
|
|
|
lastTag := r.LastTag()
|
|
|
|
_, out := r.Status.RunCmd([]string{"git", "log", "-1", "--format=%at", lastTag})
|
2024-02-14 15:17:42 -06:00
|
|
|
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()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|