From a887aa4758cfa8b95be9a132ee4bdff2457dcb42 Mon Sep 17 00:00:00 2001 From: Ahmed Magdy Date: Tue, 29 Jul 2025 01:28:58 +0200 Subject: [PATCH 1/5] Update find-latest to work with a default value --- git-artifact | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-artifact b/git-artifact index 58a38cb..4e3fbd0 100755 --- a/git-artifact +++ b/git-artifact @@ -332,7 +332,7 @@ cmd_fetch-co() { find-latest() { local -n _latest_tag=${1} # https://stackoverflow.com/questions/10649814/get-last-git-tag-from-a-remote-repo-without-cloning - _latest_tag=$(git ls-remote --tags --refs --sort='-version:refname' origin ${arg_regex} | head -n 1 | cut -f2 | cut -d / -f3-) || { + _latest_tag=$(git ls-remote --tags --refs --sort='-version:refname' origin "${arg_regex:-*}" | head -n 1 | cut -f2 | cut -d / -f3-) || { local exit_code=$? if [[ $exit_code -ne 141 ]]; then #https://unix.stackexchange.com/questions/580117/debugging-sporadic-141-shell-script-errors From af2a6626dba1ad86d7d5b57bf49a85f485c16c53 Mon Sep 17 00:00:00 2001 From: Ahmed Magdy Date: Tue, 29 Jul 2025 01:29:24 +0200 Subject: [PATCH 2/5] Update find-latest & fetch-co-latest to show an info message instead of an error --- git-artifact | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/git-artifact b/git-artifact index 4e3fbd0..2a049fc 100755 --- a/git-artifact +++ b/git-artifact @@ -498,9 +498,8 @@ main () { . git-sh-setup require_work_tree if test -z "${arg_regex:-}" ; then - git artifact -h - echo "ERROR: -r|--regex is required for $arg_command" - exit 1 + echo "INFO: -r|--regex is not set: Defaulting to '*' (all tags)." + arg_regex="*" fi ;; fetch-tags) From eb720cd4b3a2ab28eceb93835fe4776b0c58f2a1 Mon Sep 17 00:00:00 2001 From: Ahmed Magdy Date: Tue, 29 Jul 2025 01:29:48 +0200 Subject: [PATCH 3/5] Comment out the info on find-latest for now --- git-artifact | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/git-artifact b/git-artifact index 2a049fc..5832de0 100755 --- a/git-artifact +++ b/git-artifact @@ -497,10 +497,10 @@ main () { # shellcheck source=/dev/null . git-sh-setup require_work_tree - if test -z "${arg_regex:-}" ; then - echo "INFO: -r|--regex is not set: Defaulting to '*' (all tags)." - arg_regex="*" - fi + # if test -z "${arg_regex:-}" ; then + # echo "INFO: -r|--regex is not set: Defaulting to '*' (all tags)." + # arg_regex="*" + # fi ;; fetch-tags) # shellcheck source=/dev/null From 3bf9c2f010e03f8c1922394c8cab0d6990fa38ac Mon Sep 17 00:00:00 2001 From: Ahmed Magdy Date: Tue, 29 Jul 2025 11:15:31 +0200 Subject: [PATCH 4/5] default arg_regex in the main method instead of ${:-*} syntax to avoid globbing files --- git-artifact | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/git-artifact b/git-artifact index 5832de0..6674c03 100755 --- a/git-artifact +++ b/git-artifact @@ -332,11 +332,11 @@ cmd_fetch-co() { find-latest() { local -n _latest_tag=${1} # https://stackoverflow.com/questions/10649814/get-last-git-tag-from-a-remote-repo-without-cloning - _latest_tag=$(git ls-remote --tags --refs --sort='-version:refname' origin "${arg_regex:-*}" | head -n 1 | cut -f2 | cut -d / -f3-) || { + _latest_tag=$(git ls-remote --tags --refs --sort='-version:refname' origin "refs/tags/${arg_regex}" | head -n 1 | cut -f2 | cut -d / -f3-) || { local exit_code=$? if [[ $exit_code -ne 141 ]]; then #https://unix.stackexchange.com/questions/580117/debugging-sporadic-141-shell-script-errors - echo "ERROR: Something unknown happend.." + echo "ERROR: Something unknown happened.." exit 1 fi } @@ -497,10 +497,10 @@ main () { # shellcheck source=/dev/null . git-sh-setup require_work_tree - # if test -z "${arg_regex:-}" ; then - # echo "INFO: -r|--regex is not set: Defaulting to '*' (all tags)." - # arg_regex="*" - # fi + if test -z "${arg_regex:-}" ; then + # echo "INFO: -r|--regex is not set: Defaulting to '*' (all tags)." + arg_regex="*" + fi ;; fetch-tags) # shellcheck source=/dev/null From 6f45f4fdafe63fafcac410cc6353dca85e04b40f Mon Sep 17 00:00:00 2001 From: Ahmed Magdy Date: Tue, 29 Jul 2025 13:18:53 +0200 Subject: [PATCH 5/5] echo out the Info message if arg_regex is empty --- git-artifact | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-artifact b/git-artifact index 6674c03..2817dea 100755 --- a/git-artifact +++ b/git-artifact @@ -498,7 +498,7 @@ main () { . git-sh-setup require_work_tree if test -z "${arg_regex:-}" ; then - # echo "INFO: -r|--regex is not set: Defaulting to '*' (all tags)." + echo "INFO: -r|--regex is not set: Defaulting to '*' (all tags)." arg_regex="*" fi ;;