Skip to content

Commit

Permalink
Updated get_diff
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed Feb 15, 2023
1 parent 6164e1c commit 5e8b123
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions get-changed-paths.sh
Expand Up @@ -69,12 +69,11 @@ function get_diff() {
local base="$1"
local sha="$2"
local filter="$3"
local diff="${4:-$DIFF}"

while IFS='' read -r sub; do
sub_commit_pre="$(git diff "$base" "$sha" -- "$sub" | { grep '^[-]Subproject commit' || true; } | 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"
echo "::error::Failed to get previous commit for submodule ($sub) between: $base $sha"
return 1
fi

Expand All @@ -88,13 +87,13 @@ function get_diff() {
(
cd "$sub" && (
# the strange magic number is a hardcoded "empty tree" commit sha
get_diff "${sub_commit_pre:-4b825dc642cb6eb9a060e54bf8d69288fbee4904}" "${sub_commit_cur}" "$filter" ".." | awk -v r="$sub" '{ print "" r "/" $0}'
git diff --diff-filter="$filter" --name-only --ignore-submodules=all "${sub_commit_pre:-4b825dc642cb6eb9a060e54bf8d69288fbee4904}" "${sub_commit_cur}" | awk -v r="$sub" '{ print "" r "/" $0}'
)
)
fi
done < <(git submodule | awk '{print $2}')

git diff --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 -ne 0 ]]; then
echo "::error::Failed to get changed files between: $base$DIFF$sha"
Expand Down

0 comments on commit 5e8b123

Please sign in to comment.