Add version tags alongside commit hashes in output
- tools.json now has both "version" (tag) and "hash" (commit) fields - Output format: toolname@version [hash] (in duration) - Update tool fetches and stores both version and hash - Fix .gitignore to not exclude cmd/update directory
This commit is contained in:
@@ -17,6 +17,7 @@ type Tool struct {
|
||||
Name string `json:"name"`
|
||||
Package string `json:"package"`
|
||||
Version string `json:"version"`
|
||||
Hash string `json:"hash"`
|
||||
Date string `json:"date"`
|
||||
}
|
||||
|
||||
@@ -85,11 +86,15 @@ func main() {
|
||||
failed++
|
||||
} else {
|
||||
updatedTools[r.idx] = r.updated
|
||||
if r.tool.Version != r.updated.Version {
|
||||
fmt.Printf("↑ %s: %s -> %s\n", r.tool.Name, r.tool.Version, r.updated.Version)
|
||||
oldHash := r.tool.Hash
|
||||
if oldHash == "" {
|
||||
oldHash = r.tool.Version // migration from old format
|
||||
}
|
||||
if oldHash != r.updated.Hash {
|
||||
fmt.Printf("↑ %s: %s [%s] -> %s [%s]\n", r.tool.Name, r.tool.Version, shortHash(oldHash), r.updated.Version, r.updated.Hash[:12])
|
||||
changed++
|
||||
} else {
|
||||
fmt.Printf("✓ %s: %s (unchanged)\n", r.tool.Name, r.tool.Version)
|
||||
fmt.Printf("✓ %s: %s [%s] (unchanged)\n", r.tool.Name, r.updated.Version, r.updated.Hash[:12])
|
||||
}
|
||||
succeeded++
|
||||
}
|
||||
@@ -226,7 +231,8 @@ func fetchLatestVersion(tool Tool) (Tool, error) {
|
||||
return Tool{
|
||||
Name: tool.Name,
|
||||
Package: tool.Package,
|
||||
Version: fullHash,
|
||||
Version: info.Version,
|
||||
Hash: fullHash,
|
||||
Date: date,
|
||||
}, nil
|
||||
}
|
||||
@@ -243,7 +249,8 @@ func fetchLatestVersion(tool Tool) (Tool, error) {
|
||||
return Tool{
|
||||
Name: tool.Name,
|
||||
Package: tool.Package,
|
||||
Version: hash,
|
||||
Version: info.Version,
|
||||
Hash: hash,
|
||||
Date: date,
|
||||
}, nil
|
||||
}
|
||||
@@ -294,3 +301,10 @@ type result struct {
|
||||
updated Tool
|
||||
err error
|
||||
}
|
||||
|
||||
func shortHash(h string) string {
|
||||
if len(h) >= 12 {
|
||||
return h[:12]
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user