Skip to content

Commit 669dc7e

Browse files
committed
fix: scope base-ignored warning to API path
1 parent cae9006 commit 669dc7e

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob
122122
# introduced by the current branch are considered.
123123
# All files are considered as added if there is no common ancestor with
124124
# base branch or no previous commit.
125-
# This option is ignored if action is triggered by pull_request event.
125+
# This option is ignored if action is triggered by pull_request event,
126+
# unless 'token' is set to an empty string (see the 'token' input below).
126127
# Default: repository default branch (e.g. master)
127128
base: ''
128129
@@ -164,7 +165,9 @@ For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob
164165
# It's only used if action is triggered by a pull request event.
165166
# GitHub token from workflow context is used as default value.
166167
# If an empty string is provided, the action falls back to detect
167-
# changes using git commands.
168+
# changes using git commands. In that case, on pull request events
169+
# the 'base' input overrides the pull request base - e.g. set
170+
# base: ${{ github.event.before }} to detect changes since the last push.
168171
# Default: ${{ github.token }}
169172
token: ''
170173

dist/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,11 +659,11 @@ async function getChangedFiles(token, base, ref, initialFetchDepth) {
659659
if (ref) {
660660
core.warning(`'ref' input parameter is ignored when action is triggered by pull request event`);
661661
}
662-
if (base) {
663-
core.warning(`'base' input parameter is ignored when action is triggered by pull request event`);
664-
}
665662
const pr = github.context.payload.pull_request;
666663
if (token) {
664+
if (base) {
665+
core.warning(`'base' input parameter is ignored when action is triggered by pull request event and 'token' is provided - set token: '' to detect changes using git diff against 'base'`);
666+
}
667667
return await getChangedFilesFromApi(token, pr);
668668
}
669669
if (github.context.eventName === 'pull_request_target') {
@@ -673,6 +673,9 @@ async function getChangedFiles(token, base, ref, initialFetchDepth) {
673673
throw new Error(`'token' input parameter is required if action is triggered by 'pull_request_target' event`);
674674
}
675675
core.info('GitHub token is not available - changes will be detected using git diff');
676+
if (base) {
677+
core.info(`Using base '${base}' instead of the pull request base`);
678+
}
676679
const baseSha = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base.sha;
677680
const defaultBranch = (_b = github.context.payload.repository) === null || _b === void 0 ? void 0 : _b.default_branch;
678681
const currentRef = await git.getCurrentRef();

src/main.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,13 @@ async function getChangedFiles(token: string, base: string, ref: string, initial
9797
if (ref) {
9898
core.warning(`'ref' input parameter is ignored when action is triggered by pull request event`)
9999
}
100-
if (base) {
101-
core.warning(`'base' input parameter is ignored when action is triggered by pull request event`)
102-
}
103100
const pr = github.context.payload.pull_request as PullRequest
104101
if (token) {
102+
if (base) {
103+
core.warning(
104+
`'base' input parameter is ignored when action is triggered by pull request event and 'token' is provided - set token: '' to detect changes using git diff against 'base'`
105+
)
106+
}
105107
return await getChangedFilesFromApi(token, pr)
106108
}
107109
if (github.context.eventName === 'pull_request_target') {
@@ -111,6 +113,9 @@ async function getChangedFiles(token: string, base: string, ref: string, initial
111113
throw new Error(`'token' input parameter is required if action is triggered by 'pull_request_target' event`)
112114
}
113115
core.info('GitHub token is not available - changes will be detected using git diff')
116+
if (base) {
117+
core.info(`Using base '${base}' instead of the pull request base`)
118+
}
114119
const baseSha = github.context.payload.pull_request?.base.sha
115120
const defaultBranch = github.context.payload.repository?.default_branch
116121
const currentRef = await git.getCurrentRef()

0 commit comments

Comments
 (0)