Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: tj-actions/changed-files
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v23
Choose a base ref
...
head repository: tj-actions/changed-files
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v24
Choose a head ref

Commits on Jun 12, 2022

  1. Upgraded from v22.2 -> v23 (#523)

    Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
    jackton1 and jackton1 authored Jun 12, 2022
    Copy the full SHA
    6a63d1e View commit details

Commits on Jun 13, 2022

  1. Update README.md

    jackton1 authored Jun 13, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    4221d49 View commit details
  2. Update README.md

    jackton1 authored Jun 13, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d95d035 View commit details
  3. Copy the full SHA
    ad2f98e View commit details
  4. fix mispellings (#525)

    deronnax authored Jun 13, 2022
    Copy the full SHA
    4d9c041 View commit details
  5. docs: add deronnax as a contributor for doc (#526)

    * docs: update README.md [skip ci]
    
    * docs: update .all-contributorsrc [skip ci]
    
    Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
    Co-authored-by: Tonye Jack <jtonye@ymail.com>
    allcontributors[bot] and jackton1 authored Jun 13, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    d9101bf View commit details

Commits on Jun 15, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0d740ca View commit details
  2. Updated README.md (#528)

    Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
    jackton1 and jackton1 authored Jun 15, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    38cf4de View commit details

Commits on Jun 22, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3fac642 View commit details

Commits on Jun 24, 2022

  1. chore: improve error handling (#533)

    * chore: improve error handling
    
    * Update test.yml
    
    * Update test.yml
    
    * Update test.yml
    
    * Update test.yml
    
    * Update test.yml
    
    * Update diff-sha.sh
    
    * Update diff-sha.sh
    
    * updated command.
    
    * Updated message level.
    
    * Updated message.
    
    * Updated message.
    jackton1 authored Jun 24, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    3df9c18 View commit details
  2. Copy the full SHA
    34a865a View commit details
  3. Upgraded from v23 -> v23.1 (#535)

    Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
    jackton1 and jackton1 authored Jun 24, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8f98569 View commit details

Commits on Jun 28, 2022

  1. Update README.md (#536)

    * Update README.md
    
    Make it extra clear that some of these outputs only work if the `files` parameter has been specified. If `files` has not been specified, then they don't work.
    
    * Apply suggestions from code review
    
    * Update README.md
    
    Co-authored-by: Tonye Jack <jtonye@ymail.com>
    JoeOvo and jackton1 authored Jun 28, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    736c959 View commit details
  2. docs: add JoeOvo as a contributor for doc (#537)

    * docs: update README.md [skip ci]
    
    * docs: update .all-contributorsrc [skip ci]
    
    Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
    allcontributors[bot] authored Jun 28, 2022
    Copy the full SHA
    7d9d8db View commit details

Commits on Jun 29, 2022

  1. Update README.md (#538)

    jackton1 authored Jun 29, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    5eb9d8c View commit details

Commits on Jun 30, 2022

  1. Updated README.md (#540)

    Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
    jackton1 and jackton1 authored Jun 30, 2022
    Copy the full SHA
    665f0cd View commit details
  2. chore: update test (#539)

    * chore: update test
    
    * Update test.yml
    
    * Update test.yml
    jackton1 authored Jun 30, 2022
    Copy the full SHA
    e2e05ab View commit details

Commits on Jul 1, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    lpulley Logan Pulley
    Copy the full SHA
    fcfb368 View commit details

Commits on Jul 7, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    lpulley Logan Pulley
    Copy the full SHA
    8acdf5a View commit details

Commits on Jul 18, 2022

  1. feat: fix bug with similar commit hashes. (#549)

    * feat: improve error handling when similar commit hashed are detected.
    
    * Updated triggered event
    
    * Update debug message.
    
    * Removed --no-merges restriction.
    
    * Update to use qoutes.
    
    * updated git fetch.
    jackton1 authored Jul 18, 2022
    Copy the full SHA
    b2ee165 View commit details
  2. Upgraded from v23.1 -> v23.2 (#551)

    Co-authored-by: jacktony1 <jacktony1@users.noreply.github.com>
    jackton1 and jacktony1 authored Jul 18, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    22dc974 View commit details

Commits on Jul 21, 2022

  1. Verified

    This commit was signed with the committer’s verified signature.
    lpulley Logan Pulley
    Copy the full SHA
    c07b760 View commit details
  2. chore: update README.md (#552)

    * chore: update README.md
    
    * Update README.md
    jackton1 authored Jul 21, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    ce1dc84 View commit details

Commits on Jul 22, 2022

  1. Copy the full SHA
    6c44eb8 View commit details
Showing with 236 additions and 69 deletions.
  1. +18 −0 .all-contributorsrc
  2. +1 −1 .github/workflows/codacy-analysis.yml
  3. +1 −0 .github/workflows/manual-test.yml
  4. +1 −1 .github/workflows/sync-release-version.yml
  5. +50 −0 .github/workflows/test.yml
  6. +1 −1 .github/workflows/update-readme.yml
  7. +86 −18 HISTORY.md
  8. +35 −33 README.md
  9. +42 −14 diff-sha.sh
  10. +1 −1 entrypoint.sh
18 changes: 18 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
@@ -105,6 +105,24 @@
"contributions": [
"code"
]
},
{
"login": "deronnax",
"name": "Mathieu Dupuy",
"avatar_url": "https://avatars.githubusercontent.com/u/439279?v=4",
"profile": "https://github.com/deronnax",
"contributions": [
"doc"
]
},
{
"login": "JoeOvo",
"name": "Joe Moggridge",
"avatar_url": "https://avatars.githubusercontent.com/u/100686542?v=4",
"profile": "https://github.com/JoeOvo",
"contributions": [
"doc"
]
}
],
"contributorsPerLine": 7,
2 changes: 1 addition & 1 deletion .github/workflows/codacy-analysis.yml
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ jobs:

# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@4.0.2
uses: codacy/codacy-analysis-cli-action@v4.1.0
with:
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
# You can also omit the token and run the tools that support default configurations
1 change: 1 addition & 0 deletions .github/workflows/manual-test.yml
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ jobs:
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files.outputs) }}'
- name: Run changed-files with glob filtering
id: changed-files-glob
uses: ./
2 changes: 1 addition & 1 deletion .github/workflows/sync-release-version.yml
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ jobs:
paths: |
README.md
- name: Generate CHANGELOG
uses: tj-actions/github-changelog-generator@v1.13
uses: tj-actions/github-changelog-generator@v1.14
with:
output: 'HISTORY.md'
- name: Create Pull Request
50 changes: 50 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -8,6 +8,9 @@ on:
pull_request:
branches:
- main
pull_request_review:
types:
- submitted

jobs:
shellcheck:
@@ -116,6 +119,29 @@ jobs:
shell:
bash

test-similar-base-and-commit-sha:
name: Test changed-files similar base and commit sha
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
max-parallel: 4
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest, macos-11, ubuntu-18.04, windows-2022]

steps:
- name: Checkout to branch
uses: actions/checkout@v3

- name: Run changed-files with a single commit history
id: changed-files
uses: ./

- name: Show output
run: |
echo '${{ toJSON(steps.changed-files.outputs) }}'
shell:
bash

test-non-existent-base-sha:
name: Test changed-files non existent base sha
runs-on: ${{ matrix.platform }}
@@ -141,6 +167,12 @@ jobs:
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash

- name: Exit with 1 if no error is raised
if: steps.changed-files.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
exit 1
- name: Run changed-files-specific with non existent base sha
id: changed-files-specific
@@ -155,6 +187,12 @@ jobs:
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
shell:
bash

- name: Exit with 1 if no error is raised
if: steps.changed-files-specific.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files-specific.outcome }}"
exit 1
test-non-existent-sha:
name: Test changed-files non existent sha
@@ -181,6 +219,12 @@ jobs:
echo "${{ toJSON(steps.changed-files.outputs) }}"
shell:
bash

- name: Exit with 1 if no error is raised
if: steps.changed-files.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files.outcome }}"
exit 1
- name: Run changed-files-specific with non existent sha
id: changed-files-specific
@@ -195,6 +239,12 @@ jobs:
echo "${{ toJSON(steps.changed-files-specific.outputs) }}"
shell:
bash

- name: Exit with 1 if no error is raised
if: steps.changed-files-specific.outcome != 'failure'
run: |
echo "Expected: (failure) got ${{ steps.changed-files-specific.outcome }}"
exit 1
test:
name: Test changed-files
2 changes: 1 addition & 1 deletion .github/workflows/update-readme.yml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ jobs:
uses: tj-actions/remark@v3

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v9
uses: tj-actions/verify-changed-files@v10
id: verify_changed_files
with:
files: |
104 changes: 86 additions & 18 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,81 @@
# Changelog

## [Unreleased](https://github.com/tj-actions/changed-files/tree/HEAD)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v23.2...HEAD)

**Fixed bugs:**

- \[BUG\] PREVIOUS\_SHA & CURRENT\_SHA is the same when re-running a workflow, causing changed-files to be empty [\#547](https://github.com/tj-actions/changed-files/issues/547)

## [v23.2](https://github.com/tj-actions/changed-files/tree/v23.2) (2022-07-18)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v23.1...v23.2)

**Fixed bugs:**

- \[BUG\] Repo name changed, workflows are broken [\#542](https://github.com/tj-actions/changed-files/issues/542)

**Closed issues:**

- Dependency Dashboard [\#27](https://github.com/tj-actions/changed-files/issues/27)

**Merged pull requests:**

- feat: fix bug with similar commit hashes. [\#549](https://github.com/tj-actions/changed-files/pull/549) ([jackton1](https://github.com/jackton1))
- chore: update readme [\#544](https://github.com/tj-actions/changed-files/pull/544) ([jackton1](https://github.com/jackton1))
- chore\(deps\): update tj-actions/github-changelog-generator action to v1.14 [\#541](https://github.com/tj-actions/changed-files/pull/541) ([renovate[bot]](https://github.com/apps/renovate))
- Updated README.md [\#540](https://github.com/tj-actions/changed-files/pull/540) ([jackton1](https://github.com/jackton1))
- chore: update test [\#539](https://github.com/tj-actions/changed-files/pull/539) ([jackton1](https://github.com/jackton1))
- chore: update README.md [\#538](https://github.com/tj-actions/changed-files/pull/538) ([jackton1](https://github.com/jackton1))
- docs: add JoeOvo as a contributor for doc [\#537](https://github.com/tj-actions/changed-files/pull/537) ([allcontributors[bot]](https://github.com/apps/allcontributors))
- Update README.md [\#536](https://github.com/tj-actions/changed-files/pull/536) ([JoeOvo](https://github.com/JoeOvo))
- Upgraded to v23.1 [\#535](https://github.com/tj-actions/changed-files/pull/535) ([jackton1](https://github.com/jackton1))

## [v23.1](https://github.com/tj-actions/changed-files/tree/v23.1) (2022-06-24)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v23...v23.1)

**Implemented enhancements:**

- \[Feature\] implement an outputs for matrix compatible jobs [\#530](https://github.com/tj-actions/changed-files/issues/530)

**Fixed bugs:**

- \[BUG\] Misleading error if git command is missing [\#532](https://github.com/tj-actions/changed-files/issues/532)

**Merged pull requests:**

- chore: removed unused code [\#534](https://github.com/tj-actions/changed-files/pull/534) ([jackton1](https://github.com/jackton1))
- chore: improve error handling [\#533](https://github.com/tj-actions/changed-files/pull/533) ([jackton1](https://github.com/jackton1))
- chore\(deps\): update tj-actions/verify-changed-files action to v10 [\#531](https://github.com/tj-actions/changed-files/pull/531) ([renovate[bot]](https://github.com/apps/renovate))
- Updated README.md [\#528](https://github.com/tj-actions/changed-files/pull/528) ([jackton1](https://github.com/jackton1))
- chore\(deps\): update codacy/codacy-analysis-cli-action action to v4.1.0 [\#527](https://github.com/tj-actions/changed-files/pull/527) ([renovate[bot]](https://github.com/apps/renovate))
- docs: add deronnax as a contributor for doc [\#526](https://github.com/tj-actions/changed-files/pull/526) ([allcontributors[bot]](https://github.com/apps/allcontributors))
- fix mispellings [\#525](https://github.com/tj-actions/changed-files/pull/525) ([deronnax](https://github.com/deronnax))
- chore: reformat manual-test.yml [\#524](https://github.com/tj-actions/changed-files/pull/524) ([jackton1](https://github.com/jackton1))
- Upgraded to v23 [\#523](https://github.com/tj-actions/changed-files/pull/523) ([jackton1](https://github.com/jackton1))

## [v23](https://github.com/tj-actions/changed-files/tree/v23) (2022-06-12)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v22.2...v23)

**Implemented enhancements:**

- \[Feature\] Get distinct changed folders [\#504](https://github.com/tj-actions/changed-files/issues/504)

**Fixed bugs:**

- \[BUG\] Action does not work when running with `act` anymore [\#518](https://github.com/tj-actions/changed-files/issues/518)

**Merged pull requests:**

- feat: add support for returning directory names [\#522](https://github.com/tj-actions/changed-files/pull/522) ([jackton1](https://github.com/jackton1))
- feat: use debug messages for log outputs [\#521](https://github.com/tj-actions/changed-files/pull/521) ([jackton1](https://github.com/jackton1))
- chore: clean up internal variables. [\#520](https://github.com/tj-actions/changed-files/pull/520) ([jackton1](https://github.com/jackton1))
- chore\(deps\): update peter-evans/create-pull-request action to v4.0.4 [\#519](https://github.com/tj-actions/changed-files/pull/519) ([renovate[bot]](https://github.com/apps/renovate))
- Upgraded to v22.2 [\#517](https://github.com/tj-actions/changed-files/pull/517) ([jackton1](https://github.com/jackton1))

## [v22.2](https://github.com/tj-actions/changed-files/tree/v22.2) (2022-06-02)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v22.1...v22.2)
@@ -31,10 +107,6 @@

- \[Feature\] since\_last\_passing\_remote\_commit [\#507](https://github.com/tj-actions/changed-files/issues/507)

**Closed issues:**

- Dependency Dashboard [\#27](https://github.com/tj-actions/changed-files/issues/27)

**Merged pull requests:**

- Updated README.md [\#511](https://github.com/tj-actions/changed-files/pull/511) ([jackton1](https://github.com/jackton1))
@@ -78,10 +150,6 @@

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v20...v20.1)

**Implemented enhancements:**

- \[Feature\] Rename `files` -\> `paths` [\#125](https://github.com/tj-actions/changed-files/issues/125)

**Fixed bugs:**

- \[BUG\] Glob pattern doesn't work for markdown files [\#492](https://github.com/tj-actions/changed-files/issues/492)
@@ -553,7 +621,7 @@

## [v13](https://github.com/tj-actions/changed-files/tree/v13) (2022-02-17)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v2.0.1...v13)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v12.2...v13)

**Implemented enhancements:**

@@ -572,13 +640,13 @@
- \[BUG\] wrong result of any\_change output [\#314](https://github.com/tj-actions/changed-files/issues/314)
- \[BUG\] Investigate possible bug using since\_last\_remote\_commit when force pushing changes. [\#303](https://github.com/tj-actions/changed-files/issues/303)

## [v2.0.1](https://github.com/tj-actions/changed-files/tree/v2.0.1) (2021-12-30)
## [v12.2](https://github.com/tj-actions/changed-files/tree/v12.2) (2021-12-30)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v12.2...v2.0.1)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v2.0.1...v12.2)

## [v12.2](https://github.com/tj-actions/changed-files/tree/v12.2) (2021-12-30)
## [v2.0.1](https://github.com/tj-actions/changed-files/tree/v2.0.1) (2021-12-30)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v12.1...v12.2)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v12.1...v2.0.1)

**Merged pull requests:**

@@ -1140,7 +1208,7 @@

## [v7](https://github.com/tj-actions/changed-files/tree/v7) (2021-06-09)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6...v7)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6.3...v7)

**Closed issues:**

@@ -1156,13 +1224,13 @@
- Update tj-actions/sync-release-version action to v8.7 [\#86](https://github.com/tj-actions/changed-files/pull/86) ([renovate[bot]](https://github.com/apps/renovate))
- Upgraded to v6.3 [\#85](https://github.com/tj-actions/changed-files/pull/85) ([jackton1](https://github.com/jackton1))

## [v6](https://github.com/tj-actions/changed-files/tree/v6) (2021-05-26)
## [v6.3](https://github.com/tj-actions/changed-files/tree/v6.3) (2021-05-26)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6.3...v6)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6...v6.3)

## [v6.3](https://github.com/tj-actions/changed-files/tree/v6.3) (2021-05-26)
## [v6](https://github.com/tj-actions/changed-files/tree/v6) (2021-05-26)

[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6.2...v6.3)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v6.2...v6)

**Merged pull requests:**

68 changes: 35 additions & 33 deletions README.md

Large diffs are not rendered by default.

56 changes: 42 additions & 14 deletions diff-sha.sh
Original file line number Diff line number Diff line change
@@ -2,90 +2,118 @@

set -eu

INITIAL_COMMIT="false"

echo "::group::changed-files-diff-sha"

if [[ -n $INPUT_PATH ]]; then
REPO_DIR="$GITHUB_WORKSPACE/$INPUT_PATH"

echo "::debug::Resolving repository path: $REPO_DIR"
if [[ ! -d "$REPO_DIR" ]]; then
echo "::warning::Invalid repository path: $REPO_DIR"
echo "::error::Invalid repository path: $REPO_DIR"
exit 1
fi
cd "$REPO_DIR"
fi

git --version 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?

if [[ $exit_status -ne 0 ]]; then
echo "::error::git not installed"
exit 1
fi

echo "::debug::Getting HEAD SHA..."

if [[ -z $INPUT_SHA ]]; then
CURRENT_SHA=$(git rev-list --no-merges -n 1 HEAD 2>&1) && exit_status=$? || exit_status=$?
CURRENT_SHA=$(git rev-list -n 1 "HEAD" 2>&1) && exit_status=$? || exit_status=$?
else
CURRENT_SHA=$INPUT_SHA && exit_status=$? || exit_status=$?
fi

git rev-parse --quiet --verify "$CURRENT_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?

if [[ $exit_status -ne 0 ]]; then
echo "::warning::Unable to locate the current sha: $CURRENT_SHA"
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
echo "::error::Unable to locate the current sha: $CURRENT_SHA"
git --version
echo "::error::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
exit 1
else
echo "::debug::Current SHA: $CURRENT_SHA"
fi

if [[ -z $GITHUB_BASE_REF ]]; then
TARGET_BRANCH=${GITHUB_REF/refs\/heads\//}
CURRENT_BRANCH=$TARGET_BRANCH

if [[ -z $INPUT_BASE_SHA ]]; then
git fetch --no-tags -u --progress --depth=2 origin "${CURRENT_BRANCH}":"${CURRENT_BRANCH}" &&
exit_status=$? || exit_status=$?
echo "::debug::GITHUB_BASE_REF unset using $TARGET_BRANCH..."

if [[ $(git rev-list --count HEAD) -gt 1 ]]; then
PREVIOUS_SHA=$(git rev-list --no-merges -n 1 HEAD^1 2>&1) && exit_status=$? || exit_status=$?
if [[ -z $INPUT_BASE_SHA ]]; then
if [[ $(git rev-list --count "HEAD") -gt 1 ]]; then
PREVIOUS_SHA=$(git rev-parse "@~" 2>&1) && exit_status=$? || exit_status=$?
echo "::debug::Previous SHA: $PREVIOUS_SHA"
else
PREVIOUS_SHA=$CURRENT_SHA && exit_status=$? || exit_status=$?
INITIAL_COMMIT="true"
echo "::debug::Initial commit detected"
echo "::debug::Previous SHA: $PREVIOUS_SHA"
fi
else
PREVIOUS_SHA=$INPUT_BASE_SHA && exit_status=$? || exit_status=$?
TARGET_BRANCH=$(git name-rev --name-only "$PREVIOUS_SHA" 2>&1) && exit_status=$? || exit_status=$?
echo "::debug::Previous SHA: $PREVIOUS_SHA"
echo "::debug::Target branch: $TARGET_BRANCH"
fi

git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?

if [[ $exit_status -ne 0 ]]; then
echo "::warning::Unable to locate the previous sha: $PREVIOUS_SHA"
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
echo "::error::Unable to locate the previous sha: $PREVIOUS_SHA"
echo "::error::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
exit 1
fi
else
TARGET_BRANCH=$GITHUB_BASE_REF
CURRENT_BRANCH=$GITHUB_HEAD_REF

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 --no-merges -n 1 "${TARGET_BRANCH}" 2>&1) && 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
else
git fetch --no-tags -u --progress origin --depth=1 "$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"
echo "::debug::Target branch: $TARGET_BRANCH"
fi

echo "::debug::Verifying commit SHA..."
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?

if [[ $exit_status -ne 0 ]]; then
echo "::warning::Unable to locate the previous sha: $PREVIOUS_SHA"
echo "::warning::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
echo "::error::Unable to locate the previous sha: $PREVIOUS_SHA"
echo "::error::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
exit 1
fi
fi

if [[ -n "$PREVIOUS_SHA" && -n "$CURRENT_SHA" && "$PREVIOUS_SHA" == "$CURRENT_SHA" && "$INITIAL_COMMIT" == "false" ]]; then
echo "::error::Similar commit hashes detected: previous sha: $PREVIOUS_SHA is equivalent to the current sha: $CURRENT_SHA"
echo "::error::You seem to be missing 'fetch-depth: 0' or 'fetch-depth: 2'. See https://github.com/tj-actions/changed-files#usage"
exit 1
fi

echo "::set-output name=target_branch::$TARGET_BRANCH"
echo "::set-output name=current_branch::$CURRENT_BRANCH"
echo "::set-output name=previous_sha::$PREVIOUS_SHA"
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ if [[ -n $INPUT_PATH ]]; then

echo "::debug::Resolving repository path: $REPO_DIR"
if [[ ! -d "$REPO_DIR" ]]; then
echo "::warning::Invalid repository path: $REPO_DIR"
echo "::error::Invalid repository path: $REPO_DIR"
exit 1
fi
cd "$REPO_DIR"