From de59412f4b1fc7775a44372e68ebed9038df3392 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 3 Nov 2022 07:12:26 -0600 Subject: [PATCH] Update get-changed-paths.sh --- get-changed-paths.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/get-changed-paths.sh b/get-changed-paths.sh index 5581a444..6a7ebf4a 100755 --- a/get-changed-paths.sh +++ b/get-changed-paths.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -set -exuo pipefail +set -euo pipefail INPUT_SEPARATOR="${INPUT_SEPARATOR//'%'/'%25'}" INPUT_SEPARATOR="${INPUT_SEPARATOR//'.'/'%2E'}" @@ -30,14 +30,14 @@ function get_diff() { local filter="$3" while IFS='' read -r sub; do - sub_commit_pre="$(git diff --exit-code "$base$DIFF$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" && exit_status=$? || exit_status=$? - if [[ $exit_status -gt 1 ]]; then + sub_commit_pre="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" && exit_status=$? || exit_status=$? + if [[ $exit_status -ne 0 ]]; then echo "::error::Failed to get previous commit for submodule ($sub) between: $base$DIFF$sha" exit 1 fi - sub_commit_cur="$(git diff --exit-code "$base$DIFF$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" && exit_status=$? || exit_status=$? - if [[ $exit_status -gt 1 ]]; then + sub_commit_cur="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" && exit_status=$? || exit_status=$? + if [[ $exit_status -ne 0 ]]; then echo "::error::Failed to get current commit for submodule ($sub) between: $base$DIFF$sha" exit 1 fi @@ -53,16 +53,16 @@ function get_diff() { done < <(git submodule | awk '{print $2}') if [[ "$INPUT_DIR_NAMES" == "true" ]]; then - git diff --exit-code --diff-filter="$filter" --name-only --ignore-submodules=all "$base$DIFF$sha" | xargs -I {} dirname {} | uniq && exit_status=$? || exit_status=$? + git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base$DIFF$sha" | xargs -I {} dirname {} | uniq && exit_status=$? || exit_status=$? - if [[ $exit_status -gt 1 ]]; then + if [[ $exit_status -ne 0 ]]; then echo "::error::Failed to get changed directories between: $base$DIFF$sha" exit 1 fi else - git diff --exit-code --diff-filter="$filter" --name-only --ignore-submodules=all "$base$DIFF$sha" && exit_status=$? || exit_status=$? + git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base$DIFF$sha" && exit_status=$? || exit_status=$? - if [[ $exit_status -gt 1 ]]; then + if [[ $exit_status -ne 0 ]]; then echo "::error::Failed to get changed files between: $base$DIFF$sha" exit 1 fi @@ -74,14 +74,14 @@ function get_renames() { local sha="$2" while IFS='' read -r sub; do - sub_commit_pre="$(git diff --exit-code "$base$DIFF$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" && exit_status=$? || exit_status=$? - if [[ $exit_status -gt 1 ]]; then + sub_commit_pre="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" && exit_status=$? || exit_status=$? + if [[ $exit_status -ne 0 ]]; then echo "::error::Failed to get previous commit for submodule ($sub) between: $base$DIFF$sha" exit 1 fi - sub_commit_cur="$(git diff --exit-code "$base$DIFF$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" && exit_status=$? || exit_status=$? - if [[ $exit_status -gt 1 ]]; then + sub_commit_cur="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" && exit_status=$? || exit_status=$? + if [[ $exit_status -ne 0 ]]; then echo "::error::Failed to get current commit for submodule ($sub) between: $base$DIFF$sha" exit 1 fi