From ea99abe09fd83d51294194a7e7e3a94aa6857298 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Fri, 11 Oct 2024 21:24:09 +0000 Subject: feat(yae): force pinned updates flag --- yae.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/yae.go b/yae.go index 0bcf7ed..01a06d9 100644 --- a/yae.go +++ b/yae.go @@ -187,17 +187,22 @@ func main() { }, &cli.BoolFlag{ Name: "force-hashed", - Usage: "Force updates to non-pinned sources that have an unchanged version (recalculate hash)", + Usage: "Force updates for non-pinned sources that have an unchanged version (recalculate hash)", + }, + &cli.BoolFlag{ + Name: "force-pinned", + Usage: "Force updates for all sources, including pinned sources (can be used with --force-hashed)", }, }, Action: func(c *cli.Context) error { showAll := !c.Bool("show-updated-only") && !c.Bool("show-updated-only-formatted") updates := []string{} force := c.Bool("force-hashed") + forcePinned := c.Bool("force-pinned") if c.Args().Len() == 0 { for name, value := range sources { - if updated, err := updateSource(&sources, name, value, showAll, force); err != nil { + if updated, err := updateSource(&sources, name, value, showAll, force, forcePinned); err != nil { return err } else if updated { updates = append(updates, name) @@ -206,7 +211,7 @@ func main() { } else { name := c.Args().Get(0) - if updated, err := updateSource(&sources, name, sources[name], showAll, force); err != nil { + if updated, err := updateSource(&sources, name, sources[name], showAll, force, forcePinned); err != nil { return err } else if updated { updates = append(updates, name) @@ -306,14 +311,14 @@ func fetchLatestGitTag(source Source, show bool) (string, error) { return "", fmt.Errorf("source is not a git repository") } -func updateSource(sources *Sources, name string, source Source, show bool, force bool) (bool, error) { +func updateSource(sources *Sources, name string, source Source, show bool, force bool, forcePinned bool) (bool, error) { updated := false if !sources.Exists(name) { return updated, fmt.Errorf("source does not exist") } - if source.Pinned { + if source.Pinned && !forcePinned { if show { fmt.Println("skipped update for", name, "because it is pinned") } -- cgit v1.2.3