6 Commits

Author SHA1 Message Date
Michal Dorner
ebc4d7e9eb Update CHANGELOG for v3.0.1 2024-02-15 09:20:42 +01:00
Michal Dorner
45f16f1875 Merge pull request #133 from frouioui/main
Compare base and ref when token is empty
2024-02-15 09:15:48 +01:00
Michal Dorner
5da0e4c086 Merge branch 'master' 2024-02-15 09:13:51 +01:00
Michal Dorner
1441771bbf Update README.md
Add info about v3 release to What's New section
2024-01-25 08:13:18 +01:00
Florent Poinsard
245527a2ef Merge remote-tracking branch 'upstream/master' 2022-10-26 15:40:33 +02:00
Florent Poinsard
5266f0ac59 Compare base and ref when token is empty
Signed-off-by: Florent Poinsard <florent.poinsard@outlook.fr>
2022-04-19 14:29:04 +02:00
4 changed files with 16 additions and 5 deletions

View File

@@ -1,7 +1,10 @@
# Changelog
## v3.0.1
- [Compare base and ref when token is empty](https://github.com/dorny/paths-filter/pull/133)
## v3.0.0
- [Update to Node.js 20 ](https://github.com/dorny/paths-filter/pull/210)
- [Update to Node.js 20](https://github.com/dorny/paths-filter/pull/210)
- [Update all dependencies](https://github.com/dorny/paths-filter/pull/215)
## v2.11.1

View File

@@ -72,6 +72,7 @@ For more scenarios see [examples](#examples) section.
## What's New
- New major release `v3` after update to Node 20 [Breaking change]
- Add `ref` input parameter
- Add `list-files: csv` format
- Configure matrix job to run for each folder with changes using `changes` output

8
dist/index.js vendored
View File

@@ -555,6 +555,7 @@ function getConfigFileContent(configPath) {
return fs.readFileSync(configPath, { encoding: 'utf8' });
}
async function getChangedFiles(token, base, ref, initialFetchDepth) {
var _a, _b;
// if base is 'HEAD' only local uncommitted changes will be detected
// This is the simplest case as we don't need to fetch more commits or evaluate current/before refs
if (base === git.HEAD) {
@@ -581,8 +582,11 @@ async function getChangedFiles(token, base, ref, initialFetchDepth) {
// At the same time we don't want to fetch any code from forked repository
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 from PRs merge commit');
return await git.getChangesInLastCommit();
core.info('Github token is not available - changes will be detected using git diff');
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();
return await git.getChanges(base || baseSha || defaultBranch, currentRef);
}
else {
return getChangedFilesFromGit(base, ref, initialFetchDepth);

View File

@@ -86,8 +86,11 @@ async function getChangedFiles(token: string, base: string, ref: string, initial
// At the same time we don't want to fetch any code from forked repository
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 from PRs merge commit')
return await git.getChangesInLastCommit()
core.info('Github token is not available - changes will be detected using git diff')
const baseSha = github.context.payload.pull_request?.base.sha
const defaultBranch = github.context.payload.repository?.default_branch
const currentRef = await git.getCurrentRef()
return await git.getChanges(base || baseSha || defaultBranch, currentRef)
} else {
return getChangedFilesFromGit(base, ref, initialFetchDepth)
}