mirror of
https://github.com/tj-actions/changed-files
synced 2025-01-29 03:34:50 +00:00
Merge pull request #693 from tj-actions/chore/clean-up-test
fix: bug setting until and since inputs.
This commit is contained in:
commit
210f4edecf
2 changed files with 60 additions and 37 deletions
69
.github/workflows/test.yml
vendored
69
.github/workflows/test.yml
vendored
|
@ -84,6 +84,51 @@ jobs:
|
|||
shell:
|
||||
bash
|
||||
|
||||
test-using-since-and-until:
|
||||
name: Test changed-files using since and until
|
||||
runs-on: ${{ matrix.platform }}
|
||||
if: github.event_name == 'push'
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 4
|
||||
matrix:
|
||||
platform: [ubuntu-latest, ubuntu-22.04, windows-latest, macos-latest, macos-11, ubuntu-18.04, windows-2022]
|
||||
|
||||
steps:
|
||||
- name: Checkout to branch
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- run: |
|
||||
git log -1 --format="%H" --date=local --until="2022-08-20" | grep -n 8d5c4478e28f7b7189cd93c195aa9d4f0992da90
|
||||
|
||||
- name: Run changed-files since 2022-08-19
|
||||
id: changed-files-since
|
||||
uses: ./
|
||||
continue-on-error: true
|
||||
with:
|
||||
since: "2022-08-19"
|
||||
|
||||
- name: Show output
|
||||
run: |
|
||||
echo '${{ toJSON(steps.changed-files-since.outputs) }}'
|
||||
shell:
|
||||
bash
|
||||
|
||||
- name: Run changed-files until 2022-08-20
|
||||
id: changed-files-until
|
||||
uses: ./
|
||||
continue-on-error: true
|
||||
with:
|
||||
until: "2022-08-20"
|
||||
|
||||
- name: Show output
|
||||
run: |
|
||||
echo '${{ toJSON(steps.changed-files-until.outputs) }}'
|
||||
shell:
|
||||
bash
|
||||
|
||||
test-similar-base-and-commit-sha:
|
||||
name: Test changed-files similar base and commit sha
|
||||
runs-on: ${{ matrix.platform }}
|
||||
|
@ -357,30 +402,6 @@ jobs:
|
|||
exit 1
|
||||
shell:
|
||||
bash
|
||||
- name: Run changed-files since 2022-08-19
|
||||
id: changed-files-since
|
||||
uses: ./
|
||||
continue-on-error: true
|
||||
with:
|
||||
since: "2022-08-19"
|
||||
target_branch_fetch_depth: "20000"
|
||||
- name: Show output
|
||||
run: |
|
||||
echo '${{ toJSON(steps.changed-files-since.outputs) }}'
|
||||
shell:
|
||||
bash
|
||||
- name: Run changed-files until 2022-08-20
|
||||
id: changed-files-until
|
||||
uses: ./
|
||||
continue-on-error: true
|
||||
with:
|
||||
until: "2022-08-20"
|
||||
target_branch_fetch_depth: "20000"
|
||||
- name: Show output
|
||||
run: |
|
||||
echo '${{ toJSON(steps.changed-files-until.outputs) }}'
|
||||
shell:
|
||||
bash
|
||||
- name: Run changed-files with forward slash separator
|
||||
id: changed-files-forward-slash
|
||||
uses: ./
|
||||
|
|
28
diff-sha.sh
28
diff-sha.sh
|
@ -40,19 +40,20 @@ fi
|
|||
|
||||
echo "::debug::Getting HEAD SHA..."
|
||||
|
||||
if [[ -z $INPUT_SHA ]]; then
|
||||
if [[ -n "$INPUT_UNTIL" ]]; then
|
||||
CURRENT_SHA=$(git log -1 --format="%H" --date=local --until="$INPUT_UNTIL") && exit_status=$? || exit_status=$?
|
||||
if [[ -n "$INPUT_UNTIL" ]]; then
|
||||
echo "::debug::Getting HEAD SHA for '$INPUT_UNTIL'..."
|
||||
CURRENT_SHA=$(git log -1 --format="%H" --date=local --until="$INPUT_UNTIL") && exit_status=$? || exit_status=$?
|
||||
|
||||
if [[ $exit_status -ne 0 ]]; then
|
||||
echo "::error::Invalid until date: $INPUT_UNTIL"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
CURRENT_SHA=$(git rev-list -n 1 "HEAD" 2>&1) && exit_status=$? || exit_status=$?
|
||||
if [[ $exit_status -ne 0 ]]; then
|
||||
echo "::error::Invalid until date: $INPUT_UNTIL"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
CURRENT_SHA=$INPUT_SHA; exit_status=$?
|
||||
if [[ -z $INPUT_SHA ]]; then
|
||||
CURRENT_SHA=$(git rev-list -n 1 "HEAD" 2>&1) && exit_status=$? || exit_status=$?
|
||||
else
|
||||
CURRENT_SHA=$INPUT_SHA; exit_status=$?
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "::debug::Verifying the current commit SHA: $CURRENT_SHA"
|
||||
|
@ -72,16 +73,17 @@ if [[ -z $GITHUB_BASE_REF ]]; then
|
|||
CURRENT_BRANCH=$TARGET_BRANCH && exit_status=$? || exit_status=$?
|
||||
|
||||
if [[ -z $INPUT_BASE_SHA ]]; then
|
||||
git fetch --no-tags -u --progress origin --depth="$INPUT_TARGET_BRANCH_FETCH_DEPTH" "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$?
|
||||
|
||||
if [[ -n "$INPUT_SINCE" ]]; then
|
||||
PREVIOUS_SHA=$(git log --format="%H" --date=local --since="$INPUT_SINCE" --reverse | head -n 1)
|
||||
echo "::debug::Getting base SHA for '$INPUT_SINCE'..."
|
||||
PREVIOUS_SHA=$(git log --format="%H" --date=local --since="$INPUT_SINCE" | tail -1) && exit_status=$? || exit_status=$?
|
||||
|
||||
if [[ -z "$PREVIOUS_SHA" ]]; then
|
||||
echo "::error::Unable to locate a previous commit for the specified date: $INPUT_SINCE"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
git fetch --no-tags -u --progress origin --depth="$INPUT_TARGET_BRANCH_FETCH_DEPTH" "${TARGET_BRANCH}":"${TARGET_BRANCH}" && exit_status=$? || exit_status=$?
|
||||
|
||||
PREVIOUS_SHA=""
|
||||
|
||||
if [[ "$GITHUB_EVENT_FORCED" == "false" ]]; then
|
||||
|
|
Loading…
Reference in a new issue