write out versions for go.wit.com
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
3600d4c9c1
commit
497b58cb49
|
@ -116,7 +116,7 @@ func globalBuildOptions(box *gui.Node) {
|
||||||
newBranch.AddText("devel")
|
newBranch.AddText("devel")
|
||||||
newBranch.AddText(usr.Username)
|
newBranch.AddText(usr.Username)
|
||||||
newBranch.SetText(usr.Username)
|
newBranch.SetText(usr.Username)
|
||||||
newBranch.Custom = func () {
|
newBranch.Custom = func() {
|
||||||
setBranchB.SetLabel("set current branches to " + newBranch.String())
|
setBranchB.SetLabel("set current branches to " + newBranch.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -53,7 +56,9 @@ func listWindow() {
|
||||||
lw.Draw()
|
lw.Draw()
|
||||||
box := lw.Box()
|
box := lw.Box()
|
||||||
group := box.NewGroup("list")
|
group := box.NewGroup("list")
|
||||||
group.NewButton("blah", func() {})
|
group.NewButton("make new go version list", func() {
|
||||||
|
dumpVersions()
|
||||||
|
})
|
||||||
|
|
||||||
var lines []string
|
var lines []string
|
||||||
var curs *section
|
var curs *section
|
||||||
|
@ -230,3 +235,67 @@ func dumpURL(url string) []string {
|
||||||
|
|
||||||
return strings.Split(string(bodyBytes), "\n")
|
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
|
||||||
|
hours := int(d.Hours()) % 24
|
||||||
|
days := int(d.Hours()) / 24
|
||||||
|
|
||||||
|
result := ""
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
29
repolist.go
29
repolist.go
|
@ -61,7 +61,6 @@ func (r *repo) Hide() {
|
||||||
r.userVersion.Hide()
|
r.userVersion.Hide()
|
||||||
|
|
||||||
r.dirtyLabel.Hide()
|
r.dirtyLabel.Hide()
|
||||||
r.goSumStatus.Hide()
|
|
||||||
r.statusButton.Hide()
|
r.statusButton.Hide()
|
||||||
r.hidden = true
|
r.hidden = true
|
||||||
}
|
}
|
||||||
|
@ -76,7 +75,6 @@ func (r *repo) Show() {
|
||||||
r.userVersion.Show()
|
r.userVersion.Show()
|
||||||
|
|
||||||
r.dirtyLabel.Show()
|
r.dirtyLabel.Show()
|
||||||
r.goSumStatus.Show()
|
|
||||||
r.statusButton.Show()
|
r.statusButton.Show()
|
||||||
r.hidden = false
|
r.hidden = false
|
||||||
}
|
}
|
||||||
|
@ -113,7 +111,6 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
|
||||||
newRepo.userVersion = grid.NewLabel("").SetProgName("userVersion")
|
newRepo.userVersion = grid.NewLabel("").SetProgName("userVersion")
|
||||||
|
|
||||||
newRepo.dirtyLabel = grid.NewLabel("")
|
newRepo.dirtyLabel = grid.NewLabel("")
|
||||||
newRepo.goSumStatus = grid.NewLabel("?")
|
|
||||||
|
|
||||||
newRepo.vLabel = grid.NewLabel("").SetProgName("current")
|
newRepo.vLabel = grid.NewLabel("").SetProgName("current")
|
||||||
|
|
||||||
|
@ -131,12 +128,7 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
|
||||||
newRepo.status.SetMainWorkingName(master)
|
newRepo.status.SetMainWorkingName(master)
|
||||||
newRepo.status.SetDevelWorkingName(devel)
|
newRepo.status.SetDevelWorkingName(devel)
|
||||||
newRepo.status.SetUserWorkingName(user)
|
newRepo.status.SetUserWorkingName(user)
|
||||||
/*
|
|
||||||
newRepo.status.SetDevelBranchName(devel)
|
|
||||||
newRepo.status.SetUserBranchName(user)
|
|
||||||
newRepo.status.Update()
|
|
||||||
newRepo.newScan()
|
|
||||||
*/
|
|
||||||
me.allrepos[path] = newRepo
|
me.allrepos[path] = newRepo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +147,7 @@ func repolistWindow() {
|
||||||
repoAllButtons(reposbox)
|
repoAllButtons(reposbox)
|
||||||
|
|
||||||
reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
|
reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
|
||||||
reposgrid = reposgroup.NewGrid("test", 9, 1)
|
reposgrid = reposgroup.NewGrid("test", 8, 1)
|
||||||
|
|
||||||
reposgrid.NewLabel("") // path goes here
|
reposgrid.NewLabel("") // path goes here
|
||||||
|
|
||||||
|
@ -166,7 +158,6 @@ func repolistWindow() {
|
||||||
reposgrid.NewLabel("user version")
|
reposgrid.NewLabel("user version")
|
||||||
|
|
||||||
reposgrid.NewLabel("Status")
|
reposgrid.NewLabel("Status")
|
||||||
reposgrid.NewLabel("go.sum")
|
|
||||||
|
|
||||||
reposgrid.NewLabel("Current Version").SetProgName("Current Version")
|
reposgrid.NewLabel("Current Version").SetProgName("Current Version")
|
||||||
|
|
||||||
|
@ -276,20 +267,4 @@ func repoAllButtons(box *gui.Node) {
|
||||||
repo.newScan()
|
repo.newScan()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
|
||||||
grid1.NewButton("rescan all", func() {
|
|
||||||
for _, repo := range me.allrepos {
|
|
||||||
repo.newScan()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
grid1.NewButton("repostatus.ListAll()", func() {
|
|
||||||
repostatus.ListAll()
|
|
||||||
})
|
|
||||||
|
|
||||||
grid1.NewButton("repostatus.ScanGoSrc()", func() {
|
|
||||||
repostatus.ScanGoSrc()
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue