aboutsummaryrefslogtreecommitdiff
path: root/yae.go
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-11 14:19:33 -0700
committerFuwn <[email protected]>2024-10-11 14:21:45 -0700
commitfa7a25f63dec35648abf8b6e2953edc7a7fe1dbc (patch)
treec1b9a4744154821ece1bd74d43e8016b8e3a85b5 /yae.go
parent1b2192c9e3981faacf6bb9b3027cfe7f1885e68a (diff)
downloadyae-fa7a25f63dec35648abf8b6e2953edc7a7fe1dbc.tar.xz
yae-fa7a25f63dec35648abf8b6e2953edc7a7fe1dbc.zip
feat(yae): force recalculate hash flag
Diffstat (limited to 'yae.go')
-rw-r--r--yae.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/yae.go b/yae.go
index 74e2fcd..0bcf7ed 100644
--- a/yae.go
+++ b/yae.go
@@ -185,14 +185,19 @@ func main() {
Name: "show-updated-only-formatted",
Usage: "Output a comma and/or ampersand list of updated sources, silence other output",
},
+ &cli.BoolFlag{
+ Name: "force-hashed",
+ Usage: "Force updates to non-pinned sources that have an unchanged version (recalculate hash)",
+ },
},
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")
if c.Args().Len() == 0 {
for name, value := range sources {
- if updated, err := updateSource(&sources, name, value, showAll); err != nil {
+ if updated, err := updateSource(&sources, name, value, showAll, force); err != nil {
return err
} else if updated {
updates = append(updates, name)
@@ -201,7 +206,7 @@ func main() {
} else {
name := c.Args().Get(0)
- if updated, err := updateSource(&sources, name, sources[name], showAll); err != nil {
+ if updated, err := updateSource(&sources, name, sources[name], showAll, force); err != nil {
return err
} else if updated {
updates = append(updates, name)
@@ -301,7 +306,7 @@ 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) (bool, error) {
+func updateSource(sources *Sources, name string, source Source, show bool, force bool) (bool, error) {
updated := false
if !sources.Exists(name) {
@@ -323,7 +328,7 @@ func updateSource(sources *Sources, name string, source Source, show bool) (bool
return updated, err
}
- if tag != source.Version {
+ if tag != source.Version || force {
if show {
fmt.Println("updated version for", name, "from", source.Version, "to", tag)
}
@@ -334,6 +339,12 @@ func updateSource(sources *Sources, name string, source Source, show bool) (bool
if strings.Contains(source.URLTemplate, "{version}") {
source.URL = strings.ReplaceAll(source.URLTemplate, "{version}", source.Version)
}
+ } else {
+ if show {
+ fmt.Println("skipped update for", name, "because the version is unchanged")
+ }
+
+ return updated, nil
}
}