diff --git a/addRepo.go b/addRepo.go index 78a5fac..4371cd6 100644 --- a/addRepo.go +++ b/addRepo.go @@ -2,6 +2,7 @@ package main import ( "strings" + "time" "go.wit.com/lib/gadgets" "go.wit.com/lib/gui/repostatus" @@ -36,7 +37,6 @@ func (c *controlBox) addRepo(path string) { c.grid.NextRow() c.lastTag = gadgets.NewOneLiner(c.grid, "lastTag") - c.lastTag.SetText(path) c.grid.NextRow() c.dirtyL = gadgets.NewOneLiner(c.grid, "dirty") @@ -45,6 +45,15 @@ func (c *controlBox) addRepo(path string) { c.currentL = gadgets.NewOneLiner(c.grid, "current") c.grid.NextRow() + c.buildDate = gadgets.NewOneLiner(c.grid, "Build Date") + c.grid.NextRow() + + stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC") + c.buildDate.SetText(stamp) + + c.tagDate = gadgets.NewOneLiner(c.grid, "git tag Date") + c.grid.NextRow() + c.status = repostatus.NewRepoStatusWindow(path) c.status.SetMainWorkingName("master") c.status.SetDevelWorkingName("devel") @@ -68,6 +77,9 @@ func (c *controlBox) addRepo(path string) { c.lastTag.SetText(lasttag) c.currentL.SetText(cbname + " " + cbversion) + tagDate := c.getDateStamp(lasttag) + c.tagDate.SetText(tagDate) + if c.status.Changed() { log.Warn("should scan here") } diff --git a/controlBox.go b/controlBox.go index 4d1b893..ad2966e 100644 --- a/controlBox.go +++ b/controlBox.go @@ -23,11 +23,13 @@ type controlBox struct { Description *gadgets.OneLiner // repostatus things - pathL *gadgets.OneLiner - lastTag *gadgets.OneLiner - dirtyL *gadgets.OneLiner - currentL *gadgets.OneLiner - status *repostatus.RepoStatus + pathL *gadgets.OneLiner + lastTag *gadgets.OneLiner + dirtyL *gadgets.OneLiner + currentL *gadgets.OneLiner + buildDate *gadgets.OneLiner + tagDate *gadgets.OneLiner + status *repostatus.RepoStatus } // This initializes the control box diff --git a/stateWindow.go b/stateWindow.go index d42de22..142c8b7 100644 --- a/stateWindow.go +++ b/stateWindow.go @@ -6,7 +6,9 @@ import ( "fmt" "os" "path/filepath" + "strconv" "strings" + "time" "go.wit.com/lib/gadgets" "go.wit.com/lib/gui/shell" @@ -86,17 +88,13 @@ func (c *controlBox) buildPackage() bool { debname := filename + "_" + version + "_" + arch + ".deb" - if !shell.Mkdir("files/usr/bin") { - log.Warn("mkdir failed") - return false - } - if shell.Exists("files/DEBIAN") { - if !shell.Run([]string{"rm", "-rf", "files/DEBIAN"}) { + if shell.Exists("files") { + if !shell.Run([]string{"rm", "-rf", "files"}) { log.Warn("rm failed") return false } } - if shell.Exists("files/DEBIAN") { + if shell.Exists("files") { log.Warn("rm failed") return false } @@ -104,6 +102,10 @@ func (c *controlBox) buildPackage() bool { log.Warn("mkdir failed") return false } + if !shell.Mkdir("files/usr/bin") { + log.Warn("mkdir failed") + return false + } if !shell.Run([]string{"cp", filename, "files/usr/bin"}) { log.Warn("cp failed") return false @@ -171,6 +173,11 @@ func (c *controlBox) writeFiles() bool { fmt.Fprintln(cf, "Architecture:", c.Architecture.String()) fmt.Fprintln(cf, "Depends:", c.Depends.String()) fmt.Fprintln(cf, "Build-Depends:", c.BuildDepends.String()) + stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC") + // update to now now despite what the GUI is showing + fmt.Fprintln(cf, "Package-Build-Date:", stamp) + fmt.Fprintln(cf, "Git-Tag-Date:", c.tagDate.String()) + fmt.Fprintln(cf, "Maintainer:", c.Maintainer.String()) desc := c.Description.String() parts := strings.Split(desc, "\n") @@ -186,7 +193,7 @@ func (c *controlBox) computeControlValues() bool { // get the package name from the repo name path := c.pathL.String() parts := strings.Split(path, "/") - name := parts[len(parts) - 1] + name := parts[len(parts)-1] c.Package.SetText(name) } if c.Source.String() == "" { @@ -205,7 +212,25 @@ func (c *controlBox) computeControlValues() bool { // TODO: get this from gitea (or gitlab or github, etc) // or from the README.md ? if c.Description.String() == "" { - c.Description.SetText("no control file") + c.Description.SetText("missing control file") } return true } + +// stamp := time.Now().UTC().Format("2006/01/02 15:04:05 UTC") + +func (c *controlBox) getDateStamp(tag string) string { + _, out := c.status.RunCmd([]string{"git", "log", "-1", "--format=%at", tag}) + 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 "git tag " + tag + " unknown" + } + + // Parse the Unix timestamp into a time.Time object + gitTagDate := time.Unix(gitTagTimestampInt, 0) + return gitTagDate.UTC().Format("2006/01/02 15:04:05 UTC") +}