Skip to content

Commit

Permalink
fix: bug retrieving diff with custom a base sha (#945)
Browse files Browse the repository at this point in the history
Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
  • Loading branch information
jackton1 and repo-ranger[bot] committed Jan 11, 2023
1 parent 988322a commit 487675b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
37 changes: 25 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -950,18 +950,6 @@ jobs:
fi
shell:
bash
- name: Run changed-files with custom sha
id: changed-files-custom-sha
if: github.event_name == 'pull_request' && github.event.action != 'closed'
uses: ./
with:
sha: ${{ github.event.pull_request.head.sha }}
- name: Show output
if: github.event.action != 'closed'
run: |
echo '${{ toJSON(steps.changed-files-custom-sha.outputs) }}'
shell:
bash
- name: Get branch name
id: branch-name
uses: tj-actions/branch-names@v6
Expand All @@ -984,6 +972,31 @@ jobs:
echo '${{ toJSON(steps.changed-files-custom-base-sha.outputs) }}'
shell:
bash
- name: Run changed-files with custom sha
id: changed-files-custom-sha
if: github.event_name == 'pull_request' && github.event.action != 'closed'
uses: ./
with:
sha: ${{ github.event.pull_request.head.sha }}
- name: Show output
if: github.event.action != 'closed'
run: |
echo '${{ toJSON(steps.changed-files-custom-sha.outputs) }}'
shell:
bash
- name: Run changed-files with the pull request base sha and head sha
id: changed-files-pull-request-base-sha-head-sha
if: github.event_name == 'pull_request' && github.event.action != 'closed'
uses: ./
with:
base_sha: ${{ github.event.pull_request.base.sha }}
sha: ${{ github.event.pull_request.head.sha }}
- name: Show output
if: github.event.action != 'closed'
run: |
echo '${{ toJSON(steps.changed-files-pull-request-base-sha-head-sha.outputs) }}'
shell:
bash
- name: Run changed-files with specific files (only-changed)
id: changed-files-specific-only-changed
uses: ./
Expand Down
4 changes: 4 additions & 0 deletions diff-sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ else
echo "::debug::Previous SHA: $PREVIOUS_SHA"
else
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?

if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
DIFF=".."
fi
fi

echo "::debug::Target branch: $TARGET_BRANCH"
Expand Down

0 comments on commit 487675b

Please sign in to comment.