use correct commits for diff

This commit is contained in:
MicroDev 2023-03-12 09:42:16 +05:30
parent ec74be7cb4
commit 3a4bffdd65
No known key found for this signature in database
GPG Key ID: 2C0867BE60967730
2 changed files with 3 additions and 5 deletions

View File

@ -67,11 +67,9 @@ jobs:
run: echo "HEAD_SHA=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
- name: Set base sha (pull)
if: github.event_name == 'pull_request'
run: |
git fetch --no-tags --no-recurse-submodules --depth=$((DEPTH + 1)) origin $HEAD_SHA
echo "BASE_SHA=$(git rev-list $HEAD_SHA --skip=$DEPTH --max-count=1)" >> $GITHUB_ENV
run: git cat-file -e $SHA && echo "BASE_SHA=$SHA" >> $GITHUB_ENV || true
env:
DEPTH: ${{ steps.get-last-commit-with-checks.outputs.commit_depth || github.event.pull_request.commits }}
SHA: ${{ steps.get-last-commit-with-checks.outputs.commit_sha || github.event.pull_request.base.sha }}
- name: Set head sha (push)
if: github.event_name == 'push'
run: echo "HEAD_SHA=${{ github.event.after }}" >> $GITHUB_ENV

View File

@ -89,7 +89,7 @@ elif os.environ.get("BASE_SHA") and os.environ.get("HEAD_SHA"):
print("Using files list by computing diff")
changed_files = git_diff("$BASE_SHA...$HEAD_SHA")
if os.environ.get("GITHUB_EVENT_NAME") == "pull_request":
changed_files.intersection_update(git_diff("$HEAD_SHA~...$HEAD_SHA"))
changed_files.intersection_update(git_diff("$GITHUB_SHA~...$GITHUB_SHA"))
else:
print("Using files list in CHANGED_FILES")
changed_files = set(json.loads(os.environ.get("CHANGED_FILES") or "[]"))