Skip to content

Commit

Permalink
Merge pull request #640 from tj-actions/feat/add-support-for-closed-p…
Browse files Browse the repository at this point in the history
…ull-request-with-merge-set-to-true

feat: add support for closed pull requests with merge true
  • Loading branch information
jackton1 committed Sep 24, 2022
2 parents 0144a27 + 8e99cd3 commit 8e3ce84
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Expand Up @@ -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: github.event_name == 'pull_request' && steps.changed-files.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
exit 1
- name: Show output
run: |
Expand Down
6 changes: 1 addition & 5 deletions action.yml
Expand Up @@ -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"
Expand Down Expand Up @@ -201,12 +197,12 @@ 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_<VARIABLE_NAME> 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 }}
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
Expand Down
13 changes: 2 additions & 11 deletions diff-sha.sh
Expand Up @@ -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"
Expand Down

0 comments on commit 8e3ce84

Please sign in to comment.