diff options
| author | Fuwn <[email protected]> | 2024-10-11 13:08:27 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-11 13:08:27 +0000 |
| commit | 89e6466df85bb45c13ba1ae467dfbb11c28260ee (patch) | |
| tree | d266cb65aa4181c5658ac9ecccd74a37583cce25 | |
| parent | feat(yae): tag predicate prefix trimming (diff) | |
| download | yae-89e6466df85bb45c13ba1ae467dfbb11c28260ee.tar.xz yae-89e6466df85bb45c13ba1ae467dfbb11c28260ee.zip | |
feat(yae): prevent updates with pinning
| -rw-r--r-- | sources.go | 1 | ||||
| -rw-r--r-- | yae.go | 16 |
2 files changed, 17 insertions, 0 deletions
@@ -17,6 +17,7 @@ type Source struct { URITemplate string `json:"uri_template,omitempty"` TagPredicate string `json:"tag_predicate,omitempty"` TrimTagPrefix string `json:"trim_tag_prefix,omitempty"` + Pinned bool `json:"pinned,omitempty"` } func (s *Sources) EnsureLoaded() error { @@ -97,6 +97,10 @@ func main() { Name: "trim-tag-prefix", Usage: "A prefix to trim from remote git tags", }, + &cli.BoolFlag{ + Name: "pin", + Usage: "Prevent the source from being updated", + }, }, Action: func(c *cli.Context) error { if c.Args().Len() != 2 { @@ -132,6 +136,10 @@ func main() { source.TrimTagPrefix = c.String("trim-tag-prefix") } + if c.Bool("pin") { + source.Pinned = true + } + if sha256, err := fetchSHA256(source.URI, c.Bool("unpack"), !c.Bool("silent")); err != nil { return err } else { @@ -298,6 +306,14 @@ func updateSource(sources *Sources, name string, source Source, show bool) (bool return updated, fmt.Errorf("source does not exist") } + if source.Pinned { + if show { + fmt.Println("skipped update for", name, "because it is pinned") + } + + return updated, nil + } + if source.Type == "git" { tag, err := fetchLatestGitTag(source, show) |