From 79e7f83fd45804afa568682476c5fbfef4f0a670 Mon Sep 17 00:00:00 2001 From: Geoff Kuenning Date: Tue, 10 Jun 2025 15:03:38 -0700 Subject: [PATCH 1/3] Fix some minor documentation errors --- bin/check_git | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/check_git b/bin/check_git index bc4e199..1365922 100755 --- a/bin/check_git +++ b/bin/check_git @@ -212,7 +212,7 @@ print_usage() { echo " '-b', '-B', '-t' and '-T' are mutually exclusive." echo - echo " -B [] Check if repository is checkout out on the specified branch." + echo " -B Check if repository is checkout out on the specified branch." echo " '-b', '-B', '-t' and '-T' are mutually exclusive." echo @@ -221,7 +221,7 @@ print_usage() { echo " '-b', '-B', '-t' and '-T' are mutually exclusive." echo - echo " -T [] Check if repository is checkout out on the specified tag." + echo " -T Check if repository is checkout out on the specified tag." echo " No detached HEAD or branch." echo " '-b', '-B', '-t' and '-T' are mutually exclusive." echo From c8278bfe6cd49b3d928402ad345a55ac2939f203 Mon Sep 17 00:00:00 2001 From: Geoff Kuenning Date: Tue, 10 Jun 2025 15:04:09 -0700 Subject: [PATCH 2/3] Improve verification of tags Don't assume that tags are always followed by commas. Also handle tags that are commits rather than object; git verify-tag rejects commit tags. --- bin/check_git | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/check_git b/bin/check_git index 1365922..3041a32 100755 --- a/bin/check_git +++ b/bin/check_git @@ -496,7 +496,7 @@ get_current_branch() { get_current_tag() { _path="${1}" - _tag="$( run "cd ${_path} && git log --pretty=format:'%d' --abbrev-commit --date=short -1 | grep -Eo 'tag:.*?,' | sed 's/,.*$//g' | sed 's/tag:[[:space:]]*//g'" )" + _tag="$( run "cd ${_path} && git log --pretty=format:'%d%n' --abbrev-commit --date=short -1 | grep -Eo 'tag:.*' | sed 's/[,)].*$//;s/tag:[[:space:]]*//'" )" if [ "${_tag}" = "" ]; then echo return 1 @@ -543,8 +543,8 @@ _gpg_get_HEAD_raw_gpg_info() { # If currently on a tag, verify this tag if get_current_tag "${_path}" >/dev/null 2>&1; then - _tag="$( run "cd ${_path} && git tag --contains" )" - _gpg="$( run "cd ${_path} && git verify-tag --raw ${_tag} 2>&1 || true" )" + _tag="$( run "cd ${_path} && git tag --contains" | head -1)" + _gpg="$( run "cd ${_path} && git verify-tag --raw ${_tag} 2>&1 | grep -v 'cannot verify a non-tag object of type commit' || true" )" # If not on a tag, get current commit and verify it else From e7b4a82a788f4c4c87e3bf53c28503c992046696 Mon Sep 17 00:00:00 2001 From: Geoff Kuenning Date: Tue, 10 Jun 2025 15:06:09 -0700 Subject: [PATCH 3/3] Use printf to output to log file For consistency, output to the log file using printf rather than echo. Also correct the usage of printf to be robust against the possibility that PROGRAM_EXIT_TEXT might contain a percent sign. --- bin/check_git | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/check_git b/bin/check_git index 3041a32..eed84d8 100755 --- a/bin/check_git +++ b/bin/check_git @@ -1245,10 +1245,10 @@ fi ## 07. Log to file or output? ## if [ "${OUTPUT_LOGFILE}" = "1" ]; then - echo "${PROGRAM_EXIT_TEXT}" > "${OUTPUT_LOGFILE_NAME}" + printf "%s\n" "${PROGRAM_EXIT_TEXT}" > "${OUTPUT_LOGFILE_NAME}" echo "${PROGRAM_EXIT_CODE}" >> "${OUTPUT_LOGFILE_NAME}" exit "${EXIT_SUCC}" else - printf "%s${PROGRAM_EXIT_TEXT}\n" "" + printf "%s\n" "${PROGRAM_EXIT_TEXT}" exit "${PROGRAM_EXIT_CODE}" fi