From 9af6e5a9d010d1ae8ec570390b3d793e2b70a402 Mon Sep 17 00:00:00 2001 From: Sascha Bratton Date: Thu, 2 Jul 2026 21:33:01 -0400 Subject: [PATCH] fix: scope base-ignored warning to API path (#319) --- README.md | 7 +++++-- dist/index.js | 9 ++++++--- src/main.ts | 11 ++++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0811cc7..e5d0619 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,8 @@ For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob # introduced by the current branch are considered. # All files are considered as added if there is no common ancestor with # base branch or no previous commit. - # This option is ignored if action is triggered by pull_request event. + # This option is ignored if action is triggered by pull_request event, + # unless 'token' is set to an empty string (see the 'token' input below). # Default: repository default branch (e.g. master) base: '' @@ -164,7 +165,9 @@ For more information, see [CHANGELOG](https://github.com/dorny/paths-filter/blob # It's only used if action is triggered by a pull request event. # GitHub token from workflow context is used as default value. # If an empty string is provided, the action falls back to detect - # changes using git commands. + # changes using git commands. In that case, on pull request events + # the 'base' input overrides the pull request base - e.g. set + # base: ${{ github.event.before }} to detect changes since the last push. # Default: ${{ github.token }} token: '' diff --git a/dist/index.js b/dist/index.js index a4eba75..10c9fda 100644 --- a/dist/index.js +++ b/dist/index.js @@ -659,11 +659,11 @@ async function getChangedFiles(token, base, ref, initialFetchDepth) { if (ref) { core.warning(`'ref' input parameter is ignored when action is triggered by pull request event`); } - if (base) { - core.warning(`'base' input parameter is ignored when action is triggered by pull request event`); - } const pr = github.context.payload.pull_request; if (token) { + if (base) { + 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'`); + } return await getChangedFilesFromApi(token, pr); } if (github.context.eventName === 'pull_request_target') { @@ -673,6 +673,9 @@ async function getChangedFiles(token, base, ref, initialFetchDepth) { throw new Error(`'token' input parameter is required if action is triggered by 'pull_request_target' event`); } core.info('GitHub token is not available - changes will be detected using git diff'); + if (base) { + core.info(`Using base '${base}' instead of the pull request base`); + } const baseSha = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base.sha; const defaultBranch = (_b = github.context.payload.repository) === null || _b === void 0 ? void 0 : _b.default_branch; const currentRef = await git.getCurrentRef(); diff --git a/src/main.ts b/src/main.ts index 791d8e4..6d6859d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -97,11 +97,13 @@ async function getChangedFiles(token: string, base: string, ref: string, initial if (ref) { core.warning(`'ref' input parameter is ignored when action is triggered by pull request event`) } - if (base) { - core.warning(`'base' input parameter is ignored when action is triggered by pull request event`) - } const pr = github.context.payload.pull_request as PullRequest if (token) { + if (base) { + 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'` + ) + } return await getChangedFilesFromApi(token, pr) } if (github.context.eventName === 'pull_request_target') { @@ -111,6 +113,9 @@ async function getChangedFiles(token: string, base: string, ref: string, initial throw new Error(`'token' input parameter is required if action is triggered by 'pull_request_target' event`) } core.info('GitHub token is not available - changes will be detected using git diff') + if (base) { + core.info(`Using base '${base}' instead of the pull request base`) + } const baseSha = github.context.payload.pull_request?.base.sha const defaultBranch = github.context.payload.repository?.default_branch const currentRef = await git.getCurrentRef()