Compare commits

...

10 Commits

Author SHA1 Message Date
Tonye Jack
c4d29bf5b2 Merge pull request #710 from tj-actions/chore/use-local-scoped-variables 2022-10-25 16:04:27 -06:00
Tonye Jack
995ead5584 chore: use local scoped variables 2022-10-25 15:52:44 -06:00
Tonye Jack
af3b754ee2 Merge pull request #709 from tj-actions/feat/add-support-for-fetching-more-history 2022-10-25 15:39:04 -06:00
Tonye Jack
5c9ad7fce6 Updated test.yml 2022-10-25 15:00:32 -06:00
Tonye Jack
4b455d3d83 Updated test.yml 2022-10-25 15:00:08 -06:00
Tonye Jack
941c21b681 Simplify code 2022-10-25 14:58:02 -06:00
Tonye Jack
cfc8494f3b Update README.md 2022-10-25 14:49:22 -06:00
Tonye Jack
fe56d428c0 feat: add support for fetching more history 2022-10-25 14:12:36 -06:00
Tonye Jack
f10717dc73 Merge pull request #707 from tj-actions/upgrade-to-v33.0.0 2022-10-21 10:24:31 -06:00
jackton1
e4decfd4bd Upgraded from v32 -> v33.0.0 2022-10-21 15:31:27 +00:00
6 changed files with 112 additions and 64 deletions

View File

@@ -99,7 +99,7 @@ jobs:
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Run changed-files since 2022-08-19
id: changed-files-since
uses: ./
@@ -113,13 +113,13 @@ jobs:
exit 1
shell:
bash
- 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: ./
@@ -203,8 +203,8 @@ jobs:
shell:
bash
test-single-commit-history:
name: Test changed-files single commit history
test-limited-commit-history:
name: Test changed-files with limited commit history
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
@@ -216,11 +216,10 @@ jobs:
- name: Checkout to branch
uses: actions/checkout@v3
with:
fetch-depth: 1
fetch-depth: 2
- name: Run changed-files with a single commit history
id: changed-files
continue-on-error: true
uses: ./
- name: Show output

View File

@@ -1,5 +1,35 @@
# Changelog
## [v33.0.0](https://github.com/tj-actions/changed-files/tree/v33.0.0) (2022-10-21)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v33...v33.0.0)
## [v33](https://github.com/tj-actions/changed-files/tree/v33) (2022-10-21)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v32.1.2...v33)
**Fixed bugs:**
- \[BUG\] `GITHUB_EVENT_PULL_REQUEST_BASE_SHA` isn't actually the head of the base branch, and `fetch-depth: 2` fails [\#704](https://github.com/tj-actions/changed-files/issues/704)
**Closed issues:**
- Ability to do a three dots diff [\#702](https://github.com/tj-actions/changed-files/issues/702)
- Dependency Dashboard [\#27](https://github.com/tj-actions/changed-files/issues/27)
**Merged pull requests:**
- chore: update readme [\#706](https://github.com/tj-actions/changed-files/pull/706) ([jackton1](https://github.com/jackton1))
- chore: clean up test [\#705](https://github.com/tj-actions/changed-files/pull/705) ([jackton1](https://github.com/jackton1))
- feat: switch to three dot diff [\#703](https://github.com/tj-actions/changed-files/pull/703) ([jackton1](https://github.com/jackton1))
- Updated README.md [\#701](https://github.com/tj-actions/changed-files/pull/701) ([jackton1](https://github.com/jackton1))
- chore: update readme [\#700](https://github.com/tj-actions/changed-files/pull/700) ([jackton1](https://github.com/jackton1))
- chore\(deps\): update peter-evans/create-pull-request action to v4.2.0 [\#699](https://github.com/tj-actions/changed-files/pull/699) ([renovate[bot]](https://github.com/apps/renovate))
- chore\(deps\): update pascalgn/automerge-action action to v0.15.5 [\#698](https://github.com/tj-actions/changed-files/pull/698) ([renovate[bot]](https://github.com/apps/renovate))
- chore\(deps\): update peter-evans/create-pull-request action to v4.1.4 [\#697](https://github.com/tj-actions/changed-files/pull/697) ([renovate[bot]](https://github.com/apps/renovate))
- chore\(deps\): update tj-actions/verify-changed-files action to v12 [\#696](https://github.com/tj-actions/changed-files/pull/696) ([renovate[bot]](https://github.com/apps/renovate))
- Upgraded to v32.1.2 [\#695](https://github.com/tj-actions/changed-files/pull/695) ([jackton1](https://github.com/jackton1))
## [v32.1.2](https://github.com/tj-actions/changed-files/tree/v32.1.2) (2022-10-16)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v32...v32.1.2)
@@ -37,10 +67,6 @@
- \[BUG\] runner is reporting old Node.js version. [\#678](https://github.com/tj-actions/changed-files/issues/678)
- \[BUG\] New commits pushed to the base branch results in errors when shallow history is used. [\#668](https://github.com/tj-actions/changed-files/issues/668)
**Closed issues:**
- Dependency Dashboard [\#27](https://github.com/tj-actions/changed-files/issues/27)
**Merged pull requests:**
- docs: add lpulley as a contributor for code [\#685](https://github.com/tj-actions/changed-files/pull/685) ([allcontributors[bot]](https://github.com/apps/allcontributors))
@@ -142,7 +168,7 @@
## [v30](https://github.com/tj-actions/changed-files/tree/v30) (2022-09-24)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v29...v30)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v29.0.9...v30)
**Fixed bugs:**
@@ -158,13 +184,13 @@
- chore\(deps\): update codacy/codacy-analysis-cli-action action to v4.2.0 [\#634](https://github.com/tj-actions/changed-files/pull/634) ([renovate[bot]](https://github.com/apps/renovate))
- Upgraded to v29.0.9 [\#633](https://github.com/tj-actions/changed-files/pull/633) ([jackton1](https://github.com/jackton1))
## [v29](https://github.com/tj-actions/changed-files/tree/v29) (2022-09-20)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v29.0.9...v29)
## [v29.0.9](https://github.com/tj-actions/changed-files/tree/v29.0.9) (2022-09-20)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v29.0.8...v29.0.9)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v29...v29.0.9)
## [v29](https://github.com/tj-actions/changed-files/tree/v29) (2022-09-20)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v29.0.8...v29)
**Implemented enhancements:**
@@ -1023,7 +1049,7 @@
## [v13](https://github.com/tj-actions/changed-files/tree/v13) (2022-02-17)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v12.2...v13)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v2.0.1...v13)
**Implemented enhancements:**
@@ -1042,13 +1068,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)
## [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/v2.0.1...v12.2)
## [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...v2.0.1)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v12.2...v2.0.1)
## [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.1...v12.2)
**Merged pull requests:**
@@ -1202,7 +1228,7 @@
## [v1.2.1](https://github.com/tj-actions/changed-files/tree/v1.2.1) (2021-11-08)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1.2.0...v1.2.1)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.5...v1.2.1)
**Implemented enhancements:**
@@ -1216,13 +1242,13 @@
- Update actions/checkout action to v2.4.0 [\#243](https://github.com/tj-actions/changed-files/pull/243) ([renovate[bot]](https://github.com/apps/renovate))
- Upgraded to v11.5 [\#241](https://github.com/tj-actions/changed-files/pull/241) ([jackton1](https://github.com/jackton1))
## [v1.2.0](https://github.com/tj-actions/changed-files/tree/v1.2.0) (2021-10-30)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.5...v1.2.0)
## [v11.5](https://github.com/tj-actions/changed-files/tree/v11.5) (2021-10-30)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.4...v11.5)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v1.2.0...v11.5)
## [v1.2.0](https://github.com/tj-actions/changed-files/tree/v1.2.0) (2021-10-30)
[Full Changelog](https://github.com/tj-actions/changed-files/compare/v11.4...v1.2.0)
**Merged pull requests:**

View File

@@ -69,7 +69,7 @@ jobs:
# Example 1
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
- name: List all changed files
run: |
@@ -80,7 +80,7 @@ jobs:
# Example 2
- name: Get changed files in the docs folder
id: changed-files-specific
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
files: |
docs/**
@@ -162,7 +162,7 @@ Support this project with a :star:
| json | `boolean` | `false` | `false` | Output changed files in JSON format which can be used for [matrix jobs](https://github.com/tj-actions/changed-files/blob/main/.github/workflows/manual-matrix-test.yml). |
| since | `string` | `false` | | Get changed files for commits whose timestamp is older than the given time. |
| until | `string` | `false` | | Get changed files for commits whose timestamp is earlier than the given time. |
| target\_branch\_fetch\_depth | `string` | `false` | `20` | Limit fetching commits from the target branch to a specified number. **NOTE**: This can be adjusted to resolve errors with insufficient history. See: [#668](https://github.com/tj-actions/changed-files/issues/668). |
| max\_fetch\_depth | `string` | `false` | `120` | Max limit for fetching branch history. **NOTE**: This can be adjusted to resolve errors with insufficient history. |
## Examples
@@ -173,7 +173,7 @@ Support this project with a :star:
...
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
...
```
@@ -186,7 +186,7 @@ Support this project with a :star:
...
- name: Get all changed files and use a comma separator in the output
id: changed-files
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
separator: ","
...
@@ -203,7 +203,7 @@ See [inputs](#inputs) for more information.
...
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
- name: List all added files
run: |
@@ -224,7 +224,7 @@ See [outputs](#outputs) for a list of all available outputs.
...
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
- name: Run a step if my-file.txt was modified
if: contains(steps.changed-files.outputs.modified_files, 'my-file.txt')
@@ -244,7 +244,7 @@ See [outputs](#outputs) for a list of all available outputs.
...
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
files: |
my-file.txt
@@ -267,7 +267,7 @@ See [inputs](#inputs) for more information.
...
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
files: |
my-file.txt
@@ -314,7 +314,7 @@ See [outputs](#outputs) for a list of all available outputs.
...
- name: Get changed files using a source file or list of file(s) to populate to files input.
id: changed-files-specific-source-file
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
files_from_source_file: |
test/changed-files-list.txt
@@ -332,7 +332,7 @@ See [inputs](#inputs) for more information.
...
- name: Get changed files using a source file or list of file(s) to populate to files input and optionally specify more files.
id: changed-files-specific-source-file-and-specify-files
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
files_from_source_file: |
test/changed-files-list.txt
@@ -353,7 +353,7 @@ See [inputs](#inputs) for more information.
...
- name: Get changed files using a different SHA
id: changed-files
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
sha: ${{ github.event.pull_request.head.sha }}
...
@@ -370,7 +370,7 @@ See [inputs](#inputs) for more information.
...
- name: Get changed files using a different base SHA
id: changed-files
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
base_sha: ${{ github.event.pull_request.base.sha }}
...
@@ -393,7 +393,7 @@ See [inputs](#inputs) for more information.
- name: Run changed-files with defaults in dir1
id: changed-files-for-dir1
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
path: dir1
@@ -416,7 +416,7 @@ See [inputs](#inputs) for more information.
...
- name: Run changed-files with quotepath disabled
id: changed-files-quotepath
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
quotepath: "false"
@@ -456,7 +456,7 @@ See [inputs](#inputs) for more information.
- name: Run changed-files with the commit of the last successful test workflow run
id: changed-files-base-sha-push
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
base_sha: ${{ steps.last_successful_commit_push.outputs.commit_hash }}
...
@@ -484,7 +484,7 @@ See [inputs](#inputs) for more information.
- name: Run changed-files with the commit of the last successful test workflow run on main
id: changed-files-base-sha-pull-request
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
base_sha: ${{ steps.last_successful_commit_pull_request.outputs.commit_hash }}
...
@@ -508,7 +508,7 @@ See [inputs](#inputs) for more information.
...
- name: Run changed-files with dir_names
id: changed-files-dir-names
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
dir_names: "true"
...
@@ -525,7 +525,7 @@ See [inputs](#inputs) for more information.
...
- name: Run changed-files with json output
id: changed-files-json
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
json: "true"
...
@@ -542,13 +542,13 @@ See [inputs](#inputs) for more information.
...
- name: Get changed-files since 2022-08-19
id: changed-files-since
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
since: "2022-08-19"
- name: Get changed-files until 2022-08-20
id: changed-files-until
uses: tj-actions/changed-files@v32
uses: tj-actions/changed-files@v33
with:
until: "2022-08-20"
...

View File

@@ -77,10 +77,10 @@ inputs:
description: "Output changed files in JSON format which can be used for matrix jobs"
required: false
default: "false"
target_branch_fetch_depth:
description: "Limit fetching commits from the target branch to a specified number. **NOTE**: This can be adjusted to resolve errors with insufficient history. See: [#668](https://github.com/tj-actions/changed-files/issues/668)."
max_fetch_depth:
description: "Max limit for fetching branch history. **NOTE**: This can be adjusted to resolve errors with insufficient history."
required: false
default: "20"
default: "120"
outputs:
added_files:
@@ -171,7 +171,7 @@ runs:
INPUT_SINCE: ${{ inputs.since }}
INPUT_UNTIL: ${{ inputs.until }}
INPUT_PATH: ${{ inputs.path }}
INPUT_TARGET_BRANCH_FETCH_DEPTH: ${{ inputs.target_branch_fetch_depth }}
INPUT_MAX_FETCH_DEPTH: ${{ inputs.max_fetch_depth }}
- name: Glob match
uses: tj-actions/glob@v15
id: glob

View File

@@ -67,6 +67,26 @@ else
echo "::debug::Current SHA: $CURRENT_SHA"
fi
function deepenShallowCloneToFindCommit() {
local ref="$1"
local target_branch="$2"
local depth=20
local max_depth=$INPUT_MAX_FETCH_DEPTH
while ! git rev-parse --quiet --verify "$ref^{commit}" &>/dev/null; do # !0 = true = not found
echo "::debug::Unable to find commit '$ref' in shallow clone. Increasing depth to $((depth * 2))..."
depth=$((depth * 2))
if [[ $depth -gt $max_depth ]]; then
echo "::error::Unable to find commit '$ref' in shallow clone. Maximum depth of $max_depth reached."
exit 1
fi
git fetch --no-tags -u --progress --deepen="$depth" origin "$target_branch":"$target_branch"
done
}
if [[ -z $GITHUB_BASE_REF ]]; then
echo "Running on a push event..."
TARGET_BRANCH=${GITHUB_REF/refs\/heads\//} && exit_status=$? || exit_status=$?
@@ -82,8 +102,6 @@ if [[ -z $GITHUB_BASE_REF ]]; then
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
@@ -117,6 +135,9 @@ if [[ -z $GITHUB_BASE_REF ]]; then
echo "::debug::Target branch $TARGET_BRANCH..."
echo "::debug::Current branch $CURRENT_BRANCH..."
echo "::debug::Fetching previous commit SHA: $PREVIOUS_SHA"
deepenShallowCloneToFindCommit "$PREVIOUS_SHA" "$TARGET_BRANCH"
echo "::debug::Verifying the previous commit SHA: $PREVIOUS_SHA"
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?
@@ -130,9 +151,6 @@ else
TARGET_BRANCH=$GITHUB_BASE_REF
CURRENT_BRANCH=$GITHUB_HEAD_REF
git fetch --no-tags -u --progress origin --depth="$INPUT_TARGET_BRANCH_FETCH_DEPTH" "${TARGET_BRANCH}":"${TARGET_BRANCH}" &&
exit_status=$? || exit_status=$?
if [[ -z $INPUT_BASE_SHA ]]; then
PREVIOUS_SHA=$GITHUB_EVENT_PULL_REQUEST_BASE_SHA && exit_status=$? || exit_status=$?
echo "::debug::Previous SHA: $PREVIOUS_SHA"
@@ -143,6 +161,9 @@ else
echo "::debug::Target branch: $TARGET_BRANCH"
echo "::debug::Current branch: $CURRENT_BRANCH"
echo "::debug::Fetching previous commit SHA: $PREVIOUS_SHA"
deepenShallowCloneToFindCommit "$PREVIOUS_SHA" "$TARGET_BRANCH"
echo "::debug::Verifying the previous commit SHA: $PREVIOUS_SHA"
git rev-parse --quiet --verify "$PREVIOUS_SHA^{commit}" 1>/dev/null 2>&1 && exit_status=$? || exit_status=$?

View File

@@ -25,9 +25,10 @@ if [[ -n $INPUT_DIFF_RELATIVE ]]; then
fi
function get_diff() {
base="$1"
sha="$2"
filter="$3"
local base="$1"
local sha="$2"
local filter="$3"
while IFS='' read -r sub; do
sub_commit_pre="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" && exit_status=$? || exit_status=$?
if [[ $exit_status -ne 0 ]]; then
@@ -69,8 +70,9 @@ function get_diff() {
}
function get_renames() {
base="$1"
sha="$2"
local base="$1"
local sha="$2"
while IFS='' read -r sub; do
sub_commit_pre="$(git diff "$base$DIFF$sha" -- "$sub" | grep '^[-]Subproject commit' | awk '{print $3}')" && exit_status=$? || exit_status=$?
if [[ $exit_status -ne 0 ]]; then