From 4e8b111da17b4274ab8ed3218d0b2cc50fc5a9f4 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 20 Oct 2022 13:13:05 -0600 Subject: [PATCH 1/9] feat: switch to three dot diff --- get-changed-paths.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/get-changed-paths.sh b/get-changed-paths.sh index e597d25696f..92260706bc4 100755 --- a/get-changed-paths.sh +++ b/get-changed-paths.sh @@ -24,8 +24,8 @@ function get_diff() { sha="$2" filter="$3" while IFS='' read -r sub; do - sub_commit_pre="$(git diff "$base" "$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" - sub_commit_cur="$(git diff "$base" "$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" + sub_commit_pre="$(git diff "$base"..."$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" + sub_commit_cur="$(git diff "$base"..."$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" if [ -n "$sub_commit_cur" ]; then ( cd "$sub" && ( @@ -37,9 +37,9 @@ function get_diff() { done < <(git submodule | awk '{print $2}') if [[ "$INPUT_DIR_NAMES" == "true" ]]; then - git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base" "$sha" | xargs -I {} dirname {} | uniq + git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base"..."$sha" | xargs -I {} dirname {} | uniq else - git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base" "$sha" + git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base"..."$sha" fi } @@ -47,8 +47,8 @@ function get_renames() { base="$1" sha="$2" while IFS='' read -r sub; do - sub_commit_pre="$(git diff "$base" "$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" - sub_commit_cur="$(git diff "$base" "$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" + sub_commit_pre="$(git diff "$base"..."$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" + sub_commit_cur="$(git diff "$base"..."$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" if [ -n "$sub_commit_cur" ]; then ( cd "$sub" && ( @@ -60,9 +60,9 @@ function get_renames() { done < <(git submodule | awk '{print $2}') if [[ "$INPUT_DIR_NAMES" == "true" ]]; then - git log --name-status --ignore-submodules=all "$base".."$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | xargs -I {} dirname {} | uniq + git log --name-status --ignore-submodules=all "$base"..."$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | xargs -I {} dirname {} | uniq else - git log --name-status --ignore-submodules=all "$base".."$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' + git log --name-status --ignore-submodules=all "$base"..."$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' fi } From 262238adcacac8dfe69f686953878f0f54e4f19e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 20 Oct 2022 13:17:42 -0600 Subject: [PATCH 2/9] Update get-changed-paths.sh --- get-changed-paths.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/get-changed-paths.sh b/get-changed-paths.sh index 92260706bc4..d2ca0f1d71b 100755 --- a/get-changed-paths.sh +++ b/get-changed-paths.sh @@ -8,6 +8,11 @@ INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\n'/'%0A'}" INPUT_SEPARATOR="${INPUT_SEPARATOR//$'\r'/'%0D'}" GITHUB_OUTPUT=${GITHUB_OUTPUT:-""} +DIFF="..." + +if [[ -z $GITHUB_BASE_REF ]]; then + DIFF=".." +fi if [[ $INPUT_QUOTEPATH == "false" ]]; then git config --global core.quotepath off @@ -24,8 +29,8 @@ function get_diff() { sha="$2" filter="$3" while IFS='' read -r sub; do - sub_commit_pre="$(git diff "$base"..."$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" - sub_commit_cur="$(git diff "$base"..."$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" + sub_commit_pre="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" + sub_commit_cur="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" if [ -n "$sub_commit_cur" ]; then ( cd "$sub" && ( @@ -37,9 +42,9 @@ function get_diff() { done < <(git submodule | awk '{print $2}') if [[ "$INPUT_DIR_NAMES" == "true" ]]; then - git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base"..."$sha" | xargs -I {} dirname {} | uniq + git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base$DIFF$sha" | xargs -I {} dirname {} | uniq else - git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base"..."$sha" + git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base$DIFF$sha" fi } @@ -47,8 +52,8 @@ function get_renames() { base="$1" sha="$2" while IFS='' read -r sub; do - sub_commit_pre="$(git diff "$base"..."$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" - sub_commit_cur="$(git diff "$base"..."$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" + sub_commit_pre="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" + sub_commit_cur="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" if [ -n "$sub_commit_cur" ]; then ( cd "$sub" && ( @@ -60,9 +65,9 @@ function get_renames() { done < <(git submodule | awk '{print $2}') if [[ "$INPUT_DIR_NAMES" == "true" ]]; then - git log --name-status --ignore-submodules=all "$base"..."$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | xargs -I {} dirname {} | uniq + git log --name-status --ignore-submodules=all "$base$DIFF$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | xargs -I {} dirname {} | uniq else - git log --name-status --ignore-submodules=all "$base"..."$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' + git log --name-status --ignore-submodules=all "$base$DIFF$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' fi } From 8e3e2f13a8cf908cf850e887cfd30ff8ebf38916 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Thu, 20 Oct 2022 13:19:57 -0600 Subject: [PATCH 3/9] Update action.yml --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 9c47d21da0b..8878f52ab08 100644 --- a/action.yml +++ b/action.yml @@ -194,6 +194,7 @@ runs: shell: bash env: GITHUB_WORKSPACE: ${{ github.workspace }} + GITHUB_BASE_REF: ${{ github.base_ref }} # INPUT_ is not available in Composite run steps # https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#example-specifying-inputs INPUT_FILES_PATTERN_FILE: ${{ steps.glob.outputs.paths-output-file }} From ca3088a08d2bceba1e288f27a58f38244b1385b3 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 21 Oct 2022 06:37:03 -0600 Subject: [PATCH 4/9] Update get-changed-paths.sh --- get-changed-paths.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get-changed-paths.sh b/get-changed-paths.sh index d2ca0f1d71b..266d3f9f34f 100755 --- a/get-changed-paths.sh +++ b/get-changed-paths.sh @@ -11,7 +11,7 @@ GITHUB_OUTPUT=${GITHUB_OUTPUT:-""} DIFF="..." if [[ -z $GITHUB_BASE_REF ]]; then - DIFF=".." + DIFF=" " fi if [[ $INPUT_QUOTEPATH == "false" ]]; then From 627dfaf0695fcf13025f66073831097546fa065b Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 21 Oct 2022 06:45:37 -0600 Subject: [PATCH 5/9] Update get-changed-paths.sh --- get-changed-paths.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/get-changed-paths.sh b/get-changed-paths.sh index 266d3f9f34f..d2ca0f1d71b 100755 --- a/get-changed-paths.sh +++ b/get-changed-paths.sh @@ -11,7 +11,7 @@ GITHUB_OUTPUT=${GITHUB_OUTPUT:-""} DIFF="..." if [[ -z $GITHUB_BASE_REF ]]; then - DIFF=" " + DIFF=".." fi if [[ $INPUT_QUOTEPATH == "false" ]]; then From dd5ec50e4b701a7c982dffccd3ba0bcf6e1bfe92 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 21 Oct 2022 06:58:29 -0600 Subject: [PATCH 6/9] Update error handling. --- get-changed-paths.sh | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/get-changed-paths.sh b/get-changed-paths.sh index d2ca0f1d71b..374665321e7 100755 --- a/get-changed-paths.sh +++ b/get-changed-paths.sh @@ -42,9 +42,19 @@ function get_diff() { done < <(git submodule | awk '{print $2}') if [[ "$INPUT_DIR_NAMES" == "true" ]]; then - git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base$DIFF$sha" | xargs -I {} dirname {} | uniq + git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base$DIFF$sha" | xargs -I {} dirname {} | uniq && exit_status=$? || exit_status=$? + + if [[ $exit_status -ne 0 ]]; then + echo "::error::Failed to get changed directories between: $base$DIFF$sha" + exit 1 + fi else - git diff --diff-filter="$filter" --name-only --ignore-submodules=all "$base$DIFF$sha" + 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 diff between: $base$DIFF$sha" + exit 1 + fi fi } @@ -65,9 +75,19 @@ function get_renames() { done < <(git submodule | awk '{print $2}') if [[ "$INPUT_DIR_NAMES" == "true" ]]; then - git log --name-status --ignore-submodules=all "$base$DIFF$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | xargs -I {} dirname {} | uniq + git log --name-status --ignore-submodules=all "$base$DIFF$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | xargs -I {} dirname {} | uniq && exit_status=$? || exit_status=$? + + if [[ $exit_status -ne 0 ]]; then + echo "::error::Failed to get renamed directories between: $base$DIFF$sha" + exit 1 + fi else - git log --name-status --ignore-submodules=all "$base$DIFF$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' + git log --name-status --ignore-submodules=all "$base$DIFF$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' && exit_status=$? || exit_status=$? + + if [[ $exit_status -ne 0 ]]; then + echo "::error::Failed to get renames between: $base$DIFF$sha" + exit 1 + fi fi } From b670630c81aa7782a9ec32c1170a36a1ebef4e7d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 21 Oct 2022 07:02:46 -0600 Subject: [PATCH 7/9] Updated error handling --- get-changed-paths.sh | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/get-changed-paths.sh b/get-changed-paths.sh index 374665321e7..08a1a98b621 100755 --- a/get-changed-paths.sh +++ b/get-changed-paths.sh @@ -29,8 +29,20 @@ function get_diff() { sha="$2" filter="$3" while IFS='' read -r sub; do - sub_commit_pre="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" - sub_commit_cur="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" + 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 "$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 + if [ -n "$sub_commit_cur" ]; then ( cd "$sub" && ( @@ -62,8 +74,20 @@ function get_renames() { base="$1" sha="$2" while IFS='' read -r sub; do - sub_commit_pre="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" - sub_commit_cur="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[+]Subproject commit' | awk '{print $3}')" + 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 "$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 + if [ -n "$sub_commit_cur" ]; then ( cd "$sub" && ( From 711eaef9ea19bd47b4479c619d4061a700777467 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 21 Oct 2022 07:06:33 -0600 Subject: [PATCH 8/9] Update spacing and revert changes to git log commands. --- get-changed-paths.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/get-changed-paths.sh b/get-changed-paths.sh index 08a1a98b621..e67dbaef9c5 100755 --- a/get-changed-paths.sh +++ b/get-changed-paths.sh @@ -30,14 +30,12 @@ function get_diff() { filter="$3" while IFS='' read -r sub; do 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 "$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 @@ -64,7 +62,7 @@ function get_diff() { 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 diff between: $base$DIFF$sha" + echo "::error::Failed to get changed files between: $base$DIFF$sha" exit 1 fi fi @@ -75,14 +73,12 @@ function get_renames() { sha="$2" while IFS='' read -r sub; do 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 "$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 @@ -99,17 +95,17 @@ function get_renames() { done < <(git submodule | awk '{print $2}') if [[ "$INPUT_DIR_NAMES" == "true" ]]; then - git log --name-status --ignore-submodules=all "$base$DIFF$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | xargs -I {} dirname {} | uniq && exit_status=$? || exit_status=$? + git log --name-status --ignore-submodules=all "$base" "$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' | xargs -I {} dirname {} | uniq && exit_status=$? || exit_status=$? if [[ $exit_status -ne 0 ]]; then - echo "::error::Failed to get renamed directories between: $base$DIFF$sha" + echo "::error::Failed to get renamed directories between: $base → $sha" exit 1 fi else - git log --name-status --ignore-submodules=all "$base$DIFF$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' && exit_status=$? || exit_status=$? + git log --name-status --ignore-submodules=all "$base" "$sha" | grep -E "^R" | awk -F '\t' -v d="$INPUT_OLD_NEW_SEPARATOR" '{print $2d$3}' && exit_status=$? || exit_status=$? if [[ $exit_status -ne 0 ]]; then - echo "::error::Failed to get renames between: $base$DIFF$sha" + echo "::error::Failed to get renamed files between: $base → $sha" exit 1 fi fi From 9403c911ce5bbfd03a3b5aaed70a25845610c24b Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 21 Oct 2022 07:10:09 -0600 Subject: [PATCH 9/9] Updated Codacy scan. --- .github/workflows/codacy-analysis.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml index e3153442ae5..01b1a2cb229 100644 --- a/.github/workflows/codacy-analysis.yml +++ b/.github/workflows/codacy-analysis.yml @@ -19,11 +19,6 @@ on: jobs: codacy-security-scan: - # Cancel other workflows that are running for the same branch - # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency - concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true name: Codacy Security Scan runs-on: ubuntu-latest steps: