mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-04-07 02:46:50 +00:00
fix(gittag): produce correct filenames, versions, and format for git assets
- gittag classifier: use "{repo}-{tag}" filenames (matching Node.js),
strip "v" prefix from version, synthesize date-based version for
tagless repos (HEAD of master/main)
- GitHub source-only: use "git" format (no dot) and "{repo}-{tag}"
filename for clone assets
- Legacy export: add "git" to recognized formats so gittag packages
appear in the legacy cache
- Derives repo name from the git URL in releases.conf
vim-commentary now matches. vim-zig matches on format but has newer
data (expected — Go fetched more recently than Node.js).
This commit is contained in:
@@ -463,7 +463,7 @@ func classifyPackage(pkg string, conf *installerconf.Conf, d *rawcache.Dir) ([]s
|
||||
case "nodedist":
|
||||
return classifyNodeDist(pkg, conf, d)
|
||||
case "gittag":
|
||||
return classifyGitTag(pkg, d)
|
||||
return classifyGitTag(pkg, conf, d)
|
||||
case "gitea":
|
||||
return classifyGitea(pkg, conf, d)
|
||||
case "chromedist":
|
||||
@@ -633,10 +633,10 @@ func classifyGitHub(pkg string, conf *installerconf.Conf, d *rawcache.Dir) ([]st
|
||||
// Git clone asset — same as gittag source.
|
||||
gitURL := fmt.Sprintf("https://github.com/%s/%s.git", owner, repo)
|
||||
assets = append(assets, storage.Asset{
|
||||
Filename: tag,
|
||||
Filename: repo + "-" + tag,
|
||||
Version: version,
|
||||
Channel: channel,
|
||||
Format: ".git",
|
||||
Format: "git",
|
||||
Download: gitURL,
|
||||
Date: date,
|
||||
})
|
||||
@@ -799,12 +799,21 @@ type gitTagEntry struct {
|
||||
Date string `json:"Date"`
|
||||
}
|
||||
|
||||
func classifyGitTag(pkg string, d *rawcache.Dir) ([]storage.Asset, error) {
|
||||
func classifyGitTag(pkg string, conf *installerconf.Conf, d *rawcache.Dir) ([]storage.Asset, error) {
|
||||
releases, err := readAllRaw(d)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Derive repo name from the git URL for filenames.
|
||||
// "https://github.com/tpope/vim-commentary.git" → "vim-commentary"
|
||||
gitURL := conf.BaseURL
|
||||
repoName := pkg
|
||||
if gitURL != "" {
|
||||
base := filepath.Base(gitURL)
|
||||
repoName = strings.TrimSuffix(base, ".git")
|
||||
}
|
||||
|
||||
var assets []storage.Asset
|
||||
for _, data := range releases {
|
||||
var entry gitTagEntry
|
||||
@@ -812,17 +821,32 @@ func classifyGitTag(pkg string, d *rawcache.Dir) ([]storage.Asset, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
version := strings.TrimPrefix(entry.Version, "v")
|
||||
date := ""
|
||||
if len(entry.Date) >= 10 {
|
||||
date = entry.Date[:10]
|
||||
}
|
||||
|
||||
var filename string
|
||||
if version != "" {
|
||||
// Tagged release: "{repo}-{tag}" (e.g. "vim-commentary-v1.2")
|
||||
filename = repoName + "-" + entry.GitTag
|
||||
} else if len(entry.Date) >= 19 {
|
||||
// Tagless repo (HEAD of master/main): synthesize a date-based
|
||||
// version like Node.js does: "2023.10.10-18.42.21"
|
||||
version = strings.ReplaceAll(entry.Date[:10], "-", ".") +
|
||||
"-" + strings.ReplaceAll(entry.Date[11:19], ":", ".")
|
||||
filename = repoName + "-v" + version
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
|
||||
assets = append(assets, storage.Asset{
|
||||
Filename: entry.GitTag,
|
||||
Version: entry.Version,
|
||||
Filename: filename,
|
||||
Version: version,
|
||||
Channel: "stable",
|
||||
Format: ".git",
|
||||
Download: entry.GitTag,
|
||||
Format: "git",
|
||||
Download: gitURL,
|
||||
Date: date,
|
||||
Extra: "commit:" + entry.CommitHash,
|
||||
})
|
||||
|
||||
@@ -81,6 +81,7 @@ var legacyFormats = map[string]bool{
|
||||
".msi": true,
|
||||
".exe": true,
|
||||
".dmg": true,
|
||||
"git": true,
|
||||
}
|
||||
|
||||
// ExportLegacy converts PackageData to the LegacyCache wire format.
|
||||
|
||||
Reference in New Issue
Block a user