diff --git a/bin/check_git b/bin/check_git index bc4e199..eed84d8 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 @@ -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 @@ -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