From 7939ced35ebff30c8a6e223503d68286f979c797 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 23 Sep 2022 22:56:09 -0600 Subject: [PATCH 1/5] feat: add support for closed pull requests with merge true Closes: #635 --- diff-sha.sh | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/diff-sha.sh b/diff-sha.sh index 1e17d360e1a..9116f3ba3fd 100644 --- a/diff-sha.sh +++ b/diff-sha.sh @@ -96,18 +96,9 @@ else echo "::debug::GITHUB_BASE_REF: $TARGET_BRANCH..." if [[ -z $INPUT_BASE_SHA ]]; then - if [[ "$INPUT_USE_FORK_POINT" == "true" ]]; then - echo "::debug::Getting fork point..." - git fetch --no-tags -u --progress origin "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$? - PREVIOUS_SHA=$(git merge-base --fork-point "${TARGET_BRANCH}" "$(git name-rev --name-only "$CURRENT_SHA")") && exit_status=$? || exit_status=$? - echo "::debug::Previous SHA: $PREVIOUS_SHA" - else - git fetch --no-tags -u --progress origin --depth=1 "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$? - PREVIOUS_SHA=$(git rev-list -n 1 "${TARGET_BRANCH}" 2>&1) && exit_status=$? || exit_status=$? - echo "::debug::Previous SHA: $PREVIOUS_SHA" - fi + PREVIOUS_SHA=$GITHUB_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$? + echo "::debug::Previous SHA: $PREVIOUS_SHA" else - git fetch --no-tags -u --progress origin --depth=1 "$(git rev-parse --verify "$INPUT_BASE_SHA")" && exit_status=$? || exit_status=$? PREVIOUS_SHA=$INPUT_BASE_SHA TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$? echo "::debug::Previous SHA: $PREVIOUS_SHA" From 69cb60a7bb87a9d390d2b019ee14333aa076838e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 23 Sep 2022 22:57:32 -0600 Subject: [PATCH 2/5] Update action.yml --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index c16392663da..999e6690e33 100644 --- a/action.yml +++ b/action.yml @@ -201,6 +201,7 @@ runs: GITHUB_HEAD_REF: ${{ github.head_ref }} GITHUB_ACTION_PATH: ${{ github.action_path }} GITHUB_WORKSPACE: ${{ github.workspace }} + GITHUB_PULL_REQUEST_BASE_SHA: ${{ github.event.pull_request.base.sha }} # INPUT_ is not available in Composite run steps # https://github.community/t/input-variable-name-is-not-available-in-composite-run-steps/127611 INPUT_SHA: ${{ steps.sha.outputs.sha }} From 1bc25030eed1f859c243babb4cf4454fc1809e91 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 23 Sep 2022 23:12:06 -0600 Subject: [PATCH 3/5] Update action.yml --- action.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/action.yml b/action.yml index 999e6690e33..bd21472b482 100644 --- a/action.yml +++ b/action.yml @@ -66,10 +66,6 @@ inputs: description: "Specify a relative path under $GITHUB_WORKSPACE to locate the repository" required: false default: "." - use_fork_point: - description: "Finds best common ancestor between two commits to use in a three-way merge as the base_sha" - default: "false" - required: false quotepath: description: "Output filenames completely verbatim by setting this to false" default: "true" @@ -207,7 +203,6 @@ runs: INPUT_SHA: ${{ steps.sha.outputs.sha }} INPUT_BASE_SHA: ${{ steps.base-sha.outputs.base_sha }} INPUT_PATH: ${{ inputs.path }} - INPUT_USE_FORK_POINT: ${{ inputs.use_fork_point }} - name: Glob match uses: tj-actions/glob@v13 id: glob From 9fdf62af89502af8cbedadaa076cbf38a5295a01 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 23 Sep 2022 23:16:40 -0600 Subject: [PATCH 4/5] Update test.yml --- .github/workflows/test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8bba7f4e22..1927d01f230 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -176,7 +176,14 @@ jobs: - name: Run changed-files with a single commit history id: changed-files + continue-on-error: true uses: ./ + + - name: Exit with 1 if no error is raised + if: steps.changed-files.outcome != 'failure' + run: | + echo "Expected: (failure) got ${{ steps.changed-files.outcome }}" + exit 1 - name: Show output run: | From 8e99cd32063d9f9372a98242b56e1fd4ad36d7b4 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 23 Sep 2022 23:26:19 -0600 Subject: [PATCH 5/5] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1927d01f230..96d0d0e1321 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -180,7 +180,7 @@ jobs: uses: ./ - name: Exit with 1 if no error is raised - if: steps.changed-files.outcome != 'failure' + if: github.event_name == 'pull_request' && steps.changed-files.outcome != 'failure' run: | echo "Expected: (failure) got ${{ steps.changed-files.outcome }}" exit 1