Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for closed pull requests with merge true #640

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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