aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-11 12:56:07 +0000
committerFuwn <[email protected]>2024-10-11 13:01:49 +0000
commit01cdbad1fa7ef5f6d748031b3b0e291405d102d7 (patch)
tree9586b869815aff09e2b429ad179fa76143995094
parentrefactor(yae): simple tag predicate handling (diff)
downloadyae-01cdbad1fa7ef5f6d748031b3b0e291405d102d7.tar.xz
yae-01cdbad1fa7ef5f6d748031b3b0e291405d102d7.zip
feat(yae): tag predicate prefix trimming
-rw-r--r--README.md11
-rw-r--r--sources.go15
-rw-r--r--yae.go12
3 files changed, 30 insertions, 8 deletions
diff --git a/README.md b/README.md
index a950689..de3077f 100644
--- a/README.md
+++ b/README.md
@@ -40,9 +40,18 @@ yae add \
zen-browser-bin \
'https://github.com/zen-browser/desktop/releases/download/{version}/zen.linux-specific.tar.bz2'
+# Adds a Yae dependency named `yaak` pinned at tag `2024.10.1` with tag trimming for updates
+yae add \
+ --type git \
+ --unpack=false \
+ --version 2024.10.1 \
+ --trim-tag-prefix v \
+ yaak \
+ 'https://github.com/yaakapp/app/releases/download/v{version}/yaak_{version}_amd64.AppImage.tar.gz'
+
# Updates all dependencies, e.g., updates the hash of `zen-browser-twilight-bin`
# and bumps the version of `zen-browser-bin` to `1.0.1-a.8`, handling URI and
-# hash recalculations
+# hash recalculations, etc.
yae update
# Only updates `zen-browser-twilight-bin`
diff --git a/sources.go b/sources.go
index 11d9715..f84c2e1 100644
--- a/sources.go
+++ b/sources.go
@@ -9,13 +9,14 @@ import (
type Sources map[string]Source
type Source struct {
- URI string `json:"url"`
- SHA256 string `json:"sha256"`
- Unpack bool `json:"unpack"`
- Type string `json:"type"`
- Version string `json:"version,omitempty"`
- URITemplate string `json:"uri_template,omitempty"`
- TagPredicate string `json:"tag_predicate,omitempty"`
+ URI string `json:"url"`
+ SHA256 string `json:"sha256"`
+ Unpack bool `json:"unpack"`
+ Type string `json:"type"`
+ Version string `json:"version,omitempty"`
+ URITemplate string `json:"uri_template,omitempty"`
+ TagPredicate string `json:"tag_predicate,omitempty"`
+ TrimTagPrefix string `json:"trim_tag_prefix,omitempty"`
}
func (s *Sources) EnsureLoaded() error {
diff --git a/yae.go b/yae.go
index 9a2e73d..b69c7e3 100644
--- a/yae.go
+++ b/yae.go
@@ -93,6 +93,10 @@ func main() {
Name: "silent",
Usage: "Silence output",
},
+ &cli.StringFlag{
+ Name: "trim-tag-prefix",
+ Usage: "A prefix to trim from remote git tags",
+ },
},
Action: func(c *cli.Context) error {
if c.Args().Len() != 2 {
@@ -124,6 +128,10 @@ func main() {
source.TagPredicate = c.String("tag-predicate")
}
+ if c.String("trim-tag-prefix") != "" {
+ source.TrimTagPrefix = c.String("trim-tag-prefix")
+ }
+
if sha256, err := fetchSHA256(source.URI, c.Bool("unpack"), !c.Bool("silent")); err != nil {
return err
} else {
@@ -273,6 +281,10 @@ func fetchLatestGitTag(source Source, show bool) (string, error) {
}
}
+ if source.TrimTagPrefix != "" {
+ latest = strings.TrimPrefix(latest, source.TrimTagPrefix)
+ }
+
return latest, nil
}