fix: handling since last remote commits for the first pr branch commit (#953)
This commit is contained in:
parent
6f8a32e362
commit
e7bcef0f0b
55
.github/workflows/test.yml
vendored
55
.github/workflows/test.yml
vendored
@ -858,8 +858,11 @@ jobs:
|
|||||||
(
|
(
|
||||||
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, 'action.yml') &&
|
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, 'action.yml') &&
|
||||||
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, '.github/workflows/test.yml') &&
|
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, '.github/workflows/test.yml') &&
|
||||||
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, '.github/workflows/greetings.yml') &&
|
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, 'test/test.txt') &&
|
||||||
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, 'test/test.txt')
|
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, 'test/test2/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, 'test/test2/test3/test4/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, '[test new].txt') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.all_changed_files, '.github/workflows/greetings.yml')
|
||||||
)
|
)
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ steps.changed-files-specific-source-file.outputs.any_changed }}" != "false" ]]; then
|
if [[ "${{ steps.changed-files-specific-source-file.outputs.any_changed }}" != "false" ]]; then
|
||||||
@ -880,8 +883,11 @@ jobs:
|
|||||||
(
|
(
|
||||||
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'action.yml') &&
|
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'action.yml') &&
|
||||||
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/test.yml') &&
|
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/test.yml') &&
|
||||||
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/greetings.yml') &&
|
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'test/test.txt') &&
|
||||||
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'test/test.txt')
|
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'test/test2/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, 'test/test2/test3/test4/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '[test new].txt') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.all_modified_files, '.github/workflows/greetings.yml')
|
||||||
)
|
)
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ steps.changed-files-specific-source-file.outputs.any_modified }}" != "false" ]]; then
|
if [[ "${{ steps.changed-files-specific-source-file.outputs.any_modified }}" != "false" ]]; then
|
||||||
@ -898,7 +904,16 @@ jobs:
|
|||||||
shell:
|
shell:
|
||||||
bash
|
bash
|
||||||
- name: Verify any_deleted from source files
|
- name: Verify any_deleted from source files
|
||||||
if: "!contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-source-file.outputs.deleted_files, '.github/workflows/test.yml') && !contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'test/test.txt')"
|
if: |
|
||||||
|
(
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'action.yml') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.deleted_files, '.github/workflows/test.yml') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'test/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'test/test2/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.deleted_files, 'test/test2/test3/test4/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.deleted_files, '[test new].txt') &&
|
||||||
|
!contains(steps.changed-files-specific-source-file.outputs.deleted_files, '.github/workflows/greetings.yml')
|
||||||
|
)
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ steps.changed-files-specific-source-file.outputs.any_deleted }}" != "false" ]]; then
|
if [[ "${{ steps.changed-files-specific-source-file.outputs.any_deleted }}" != "false" ]]; then
|
||||||
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-source-file.outputs.any_deleted }})"
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-source-file.outputs.any_deleted }})"
|
||||||
@ -924,7 +939,15 @@ jobs:
|
|||||||
shell:
|
shell:
|
||||||
bash
|
bash
|
||||||
- name: Verify any_changed files comma separator
|
- name: Verify any_changed files comma separator
|
||||||
if: "!contains(steps.changed-files-specific-comma-source-file.outputs.all_changed_files, 'action.yml') && !contains(steps.changed-files-specific-comma-source-file.outputs.all_changed_files, '.github/workflows/test.yml') && !contains(steps.changed-files-specific-comma.outputs.all_changed_files, 'test/test.txt')"
|
if: |
|
||||||
|
(
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_changed_files, 'action.yml') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_changed_files, '.github/workflows/test.yml') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_changed_files, 'test/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_changed_files, 'test/test2/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_changed_files, 'test/test2/test3/test4/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_changed_files, '[test new].txt')
|
||||||
|
)
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_changed }}" != "false" ]]; then
|
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_changed }}" != "false" ]]; then
|
||||||
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_changed }})"
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_changed }})"
|
||||||
@ -933,7 +956,15 @@ jobs:
|
|||||||
shell:
|
shell:
|
||||||
bash
|
bash
|
||||||
- name: Verify any_modified files comma separator
|
- name: Verify any_modified files comma separator
|
||||||
if: "!contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, 'action.yml') && !contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, '.github/workflows/test.yml') && !contains(steps.changed-files-specific-comma.outputs.all_modified_files, 'test/test.txt')"
|
if: |
|
||||||
|
(
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, 'action.yml') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, '.github/workflows/test.yml') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, 'test/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, 'test/test2/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, 'test/test2/test3/test4/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.all_modified_files, '[test new].txt')
|
||||||
|
)
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_modified }}" != "false" ]]; then
|
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_modified }}" != "false" ]]; then
|
||||||
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_modified }})"
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_modified }})"
|
||||||
@ -942,7 +973,15 @@ jobs:
|
|||||||
shell:
|
shell:
|
||||||
bash
|
bash
|
||||||
- name: Verify any_deleted files with comma separator
|
- name: Verify any_deleted files with comma separator
|
||||||
if: "!contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, 'action.yml') && !contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, '.github/workflows/test.yml') && !contains(steps.changed-files-specific-comma.outputs.deleted_files, 'test/test.txt')"
|
if: |
|
||||||
|
(
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, 'action.yml') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, '.github/workflows/test.yml') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, 'test/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, 'test/test2/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, 'test/test2/test3/test4/test.txt') &&
|
||||||
|
!contains(steps.changed-files-specific-comma-source-file.outputs.deleted_files, '[test new].txt')
|
||||||
|
)
|
||||||
run: |
|
run: |
|
||||||
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_deleted }}" != "false" ]]; then
|
if [[ "${{ steps.changed-files-specific-comma-source-file.outputs.any_deleted }}" != "false" ]]; then
|
||||||
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_deleted }})"
|
echo "Invalid output: Expected (false) got (${{ steps.changed-files-specific-comma-source-file.outputs.any_deleted }})"
|
||||||
|
27
diff-sha.sh
27
diff-sha.sh
@ -103,20 +103,16 @@ if [[ -z $GITHUB_EVENT_PULL_REQUEST_BASE_REF ]]; then
|
|||||||
PREVIOUS_SHA=""
|
PREVIOUS_SHA=""
|
||||||
|
|
||||||
if [[ "$GITHUB_EVENT_FORCED" == "false" || -z "$GITHUB_EVENT_FORCED" ]]; then
|
if [[ "$GITHUB_EVENT_FORCED" == "false" || -z "$GITHUB_EVENT_FORCED" ]]; then
|
||||||
PREVIOUS_SHA=$GITHUB_EVENT_BEFORE
|
PREVIOUS_SHA=$GITHUB_EVENT_BEFORE && exit_status=$? || exit_status=$?
|
||||||
|
else
|
||||||
|
PREVIOUS_SHA=$(git rev-list -n 1 "HEAD~1") && exit_status=$? || exit_status=$?
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
PREVIOUS_SHA=$(git rev-list -n 1 "$TARGET_BRANCH") && exit_status=$? || exit_status=$?
|
PREVIOUS_SHA=$(git rev-list -n 1 "HEAD~1") && exit_status=$? || exit_status=$?
|
||||||
|
|
||||||
if [[ -z "$PREVIOUS_SHA" ]]; then
|
|
||||||
if [[ "$GITHUB_EVENT_FORCED" == "false" || -z "$GITHUB_EVENT_FORCED" ]]; then
|
|
||||||
PREVIOUS_SHA=$GITHUB_EVENT_BEFORE
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "0000000000000000000000000000000000000000" ]]; then
|
if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "0000000000000000000000000000000000000000" ]]; then
|
||||||
PREVIOUS_SHA=$(git rev-parse "$(git branch -r --sort=-committerdate | head -1 | xargs)")
|
PREVIOUS_SHA=$(git rev-list -n 1 "HEAD~1") && exit_status=$? || exit_status=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then
|
if [[ "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then
|
||||||
@ -161,7 +157,7 @@ else
|
|||||||
if [[ -f .git/shallow ]]; then
|
if [[ -f .git/shallow ]]; then
|
||||||
echo "Fetching remote refs..."
|
echo "Fetching remote refs..."
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
git fetch $EXTRA_ARGS -u --progress origin pull/"$GITHUB_EVENT_PULL_REQUEST_NUMBER"/head:"$CURRENT_BRANCH" 1>/dev/null
|
git fetch $EXTRA_ARGS -u --progress --deepen="$INPUT_FETCH_DEPTH" origin "$CURRENT_BRANCH" 1>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::debug::Getting HEAD SHA..."
|
echo "::debug::Getting HEAD SHA..."
|
||||||
@ -209,25 +205,24 @@ else
|
|||||||
git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" 1>/dev/null 2>&1 || true
|
git branch --track "$TARGET_BRANCH" origin/"$TARGET_BRANCH" 1>/dev/null 2>&1 || true
|
||||||
|
|
||||||
PREVIOUS_SHA=$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$?
|
PREVIOUS_SHA=$(git merge-base "$TARGET_BRANCH" "$CURRENT_SHA") && exit_status=$? || exit_status=$?
|
||||||
|
|
||||||
|
if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
|
||||||
|
PREVIOUS_SHA=$(git rev-parse "$TARGET_BRANCH") && exit_status=$? || exit_status=$?
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then
|
if [[ -z "$PREVIOUS_SHA" || "$PREVIOUS_SHA" == "$CURRENT_SHA" ]]; then
|
||||||
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
|
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
|
|
||||||
PREVIOUS_SHA=$(git rev-parse "$TARGET_BRANCH") && exit_status=$? || exit_status=$?
|
|
||||||
DIFF=".."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "::debug::Previous SHA: $PREVIOUS_SHA"
|
echo "::debug::Previous SHA: $PREVIOUS_SHA"
|
||||||
else
|
else
|
||||||
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
|
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
|
||||||
|
fi
|
||||||
|
|
||||||
if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
|
if ! git diff --name-only --ignore-submodules=all "$PREVIOUS_SHA$DIFF$CURRENT_SHA" 1>/dev/null 2>&1; then
|
||||||
DIFF=".."
|
DIFF=".."
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
echo "::debug::Target branch: $TARGET_BRANCH"
|
echo "::debug::Target branch: $TARGET_BRANCH"
|
||||||
echo "::debug::Current branch: $CURRENT_BRANCH"
|
echo "::debug::Current branch: $CURRENT_BRANCH"
|
||||||
|
@ -1 +1 @@
|
|||||||
This is a test file
|
This is a test file.
|
||||||
|
@ -1 +1 @@
|
|||||||
Lorem ipsum dolor sit amet, consectetur adip eget, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
Loading…
x
Reference in New Issue
Block a user