From 4627e4849e6df96d1b18b14144d39256e606387e Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 9 Jun 2024 19:47:27 +0200 Subject: [PATCH] common-updater-scripts/u-s-v: allow omitting version with --ignore-same-version This is useful when wanting to update secondary hashes like `cargoDeps`. --- pkgs/common-updater/scripts/update-source-version | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/common-updater/scripts/update-source-version b/pkgs/common-updater/scripts/update-source-version index 37dc232f7248..8196c81054e2 100755 --- a/pkgs/common-updater/scripts/update-source-version +++ b/pkgs/common-updater/scripts/update-source-version @@ -13,6 +13,8 @@ usage() { echo " [--version-key=] [--source-key=]" echo " [--system=] [--file=] [--rev=]" echo " [--ignore-same-hash] [--ignore-same-version] [--print-changes]" + echo "" + echo "The positional argument is also optional when passing --ignore-same-version." } ignoreSameVersion= @@ -71,7 +73,13 @@ newUrl=${args[3]} # Third-party repositories might not accept arguments in their default.nix. importTree="(let tree = import ./.; in if builtins.isFunction tree then tree {} else tree)" -if (( "${#args[*]}" < 2 )); then +if [[ -z "$ignoreSameVersion" ]]; then + requiredArgs=2 +else + requiredArgs=1 +fi + +if (( "${#args[*]}" < $requiredArgs )); then echo "$scriptName: Too few arguments" usage exit 1 @@ -143,6 +151,10 @@ if [[ -z "$oldVersion" ]]; then die "Couldn't find out the old version of '$attr'!" fi +if [[ -n "$ignoreSameVersion" && -z "$newVersion" ]]; then + newVersion="$oldVersion" +fi + if [[ -z "$ignoreSameVersion" && "$oldVersion" = "$newVersion" ]]; then echo "$scriptName: New version same as old version, nothing to do." >&2 if [ -n "$printChanges" ]; then