compute the timestamps each time

This commit is contained in:
Jeff Carr 2024-12-27 20:43:23 -06:00
parent 37500b9496
commit 7a8f54a192
3 changed files with 8 additions and 34 deletions

View File

@ -99,19 +99,12 @@ func indexBodyRepo(w http.ResponseWriter, gourl string, giturl string, desc stri
// fmt.Fprintln(w, " <td>"+gourl+"</td>") // fmt.Fprintln(w, " <td>"+gourl+"</td>")
fmt.Fprintln(w, " <td> <a href=\"//"+gourl+"\">"+gourl+"</a></td>") fmt.Fprintln(w, " <td> <a href=\"//"+gourl+"\">"+gourl+"</a></td>")
fmt.Fprintln(w, " <td> <a href=\"//pkg.go.dev/"+gourl+"\"> <img src=\"goReference.svg\" alt=\"pkg.go.dev\" /> </a> </td>") fmt.Fprintln(w, " <td> <a href=\"//pkg.go.dev/"+gourl+"\"> <img src=\"goReference.svg\" alt=\"pkg.go.dev\" /> </a> </td>")
// for i, s := range versionMap {
// log.Println("found i =", i, "with", "s =", s)
// }
var vtime, version string var vtime, version string
gourl = strings.TrimSpace(gourl) gourl = strings.TrimSpace(gourl)
if tmp, ok := versionMap[gourl]; ok { if repo, ok := gitMap[gourl]; ok {
// log.Info("gopath", gopath, "tmp", tmp) version = repo.GetLastTag()
parts := strings.Fields(tmp) age := repo.NewestAge()
if len(parts) == 2 { vtime = formatDuration(age)
// log.Info("GOT HERE gopath", gopath, "tmp", tmp)
version = parts[0]
vtime = parts[1]
}
} }
log.Info("gopath", gourl, "dur", vtime, "version", version) log.Info("gopath", gourl, "dur", vtime, "version", version)

22
main.go
View File

@ -4,10 +4,10 @@ import (
"embed" "embed"
"fmt" "fmt"
"net/http" "net/http"
"strings"
"time" "time"
"go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log" "go.wit.com/log"
) )
@ -21,7 +21,7 @@ var resources embed.FS
// var accessf, clientf *os.File // var accessf, clientf *os.File
var repoMap map[string]string var repoMap map[string]string
var versionMap map[string]string var gitMap map[string]*gitpb.Repo
var configfile []string var configfile []string
var keysSorted []string var keysSorted []string
var forge *forgepb.Forge var forge *forgepb.Forge
@ -40,7 +40,7 @@ func main() {
} }
forge = forgepb.Init() forge = forgepb.Init()
versionMap = make(map[string]string) gitMap = make(map[string]*gitpb.Repo)
repoMap = make(map[string]string) repoMap = make(map[string]string)
/* /*
@ -56,22 +56,6 @@ func main() {
readRepomap() readRepomap()
// readVersionFile() // readVersionFile()
var vtime string
var version string
for gopath, thing := range versionMap {
if tmp, ok := versionMap[gopath]; ok {
// log.Info("gopath", gopath, "tmp", tmp)
parts := strings.Fields(tmp)
if len(parts) == 2 {
// log.Info("GOT HERE gopath", gopath, "tmp", tmp)
version = parts[0]
vtime = parts[1]
}
}
log.Info("gopath", gopath, "info", thing, "dur", vtime, "version", version)
}
log.Println("found log =", versionMap["go.wit.com/log"])
http.HandleFunc("/", okHandler) http.HandleFunc("/", okHandler)
// go https() // use caddy instead // go https() // use caddy instead
p := fmt.Sprintf(":%d", argv.Port) p := fmt.Sprintf(":%d", argv.Port)

View File

@ -67,10 +67,7 @@ func readRepomap() {
repo := forge.FindByGoPath(gopath) repo := forge.FindByGoPath(gopath)
if repo != nil { if repo != nil {
version := repo.GetLastTag() gitMap[gopath] = repo
age := repo.NewestAge()
log.Info("repo =", gopath, "real url =", repoMap[gopath], version, formatDuration(age))
versionMap[gopath] = version + " " + formatDuration(age)
} else { } else {
log.Info("repo =", gopath, "real url =", repoMap[gopath], "not found") log.Info("repo =", gopath, "real url =", repoMap[gopath], "not found")
} }