-
-
Notifications
You must be signed in to change notification settings - Fork 113
Add path filtering support for monorepo setups #1458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@mikepenz I tested this branch and it works as I would expect it to (using Github backend) |
|
@copilot rebase please |
I'm unable to perform git rebase operations as I don't have access to git push/rebase commands in this environment. You'll need to rebase this branch manually or through the GitHub interface. |
9660bbc to
e9894ed
Compare
|
||||||||||||||
e9894ed to
a3d6e36
Compare
cb0a5a9 to
e65be06
Compare
Co-authored-by: mikepenz <[email protected]>
…& adjust type accordingly
…ementations - Refactored `includeOnlyPaths` handling for better consistency. - Added path filtering to `getDiffStats` and `getCommitsBetween` functions. - Updated tests to reflect changes in path filtering logic. - Enhanced offline and remote repository handling with path filtering support.
…sitory - Refactored path filtering logic for better efficiency and readability. - Consolidated file matching and commit filtering to reduce redundant API calls. - Improved handling of commit-to-file mapping. - Adjusted logic to streamline stats collection and filtering process.
48da528 to
f1f0303
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for path filtering in monorepo environments by introducing an includeOnlyPaths parameter that allows filtering commits based on the files they modify. This enables users to generate changelogs that only include commits affecting specific parts of their codebase.
- Added
includeOnlyPathsinput parameter to filter commits by file paths - Updated repository implementations to support path filtering with different strategies for GitHub and Gitea
- Added comprehensive test coverage for the new functionality
Reviewed Changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| action.yml | Added includeOnlyPaths input parameter definition |
| src/main.ts | Added input processing for path patterns with filtering logic |
| src/repositories/*.ts | Updated all repository classes to support path filtering parameter |
| src/pr-collector/*.ts | Updated data flow to pass path filtering through the collection pipeline |
| tests/pathFiltering.test.ts | Added unit tests for path filtering functionality |
| README.md | Added documentation and usage examples for monorepo configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| authorName: commit.authorName, | ||
| authorDate: moment(commit.authorDate), | ||
| committer: "", | ||
| committerName: "", |
Copilot
AI
Aug 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The committer field is hardcoded to an empty string instead of using the actual commit data. This loses information that was previously available in the original implementation.
| committerName: "", | |
| committer: commit.committer ?? "", | |
| committerName: commit.committerName ?? "", |
Copilot uses AI. Check for mistakes.
| authorName: commit.authorName, | ||
| authorDate: moment(commit.authorDate), | ||
| committer: "", | ||
| committerName: "", |
Copilot
AI
Aug 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The committerName field is hardcoded to an empty string instead of using the actual commit data. This loses information that was previously available in the original implementation.
| committerName: "", | |
| committer: commit.committer, | |
| committerName: commit.committerName, |
Copilot uses AI. Check for mistakes.
| let changeCount = 0 | ||
| let commitCount = 0 | ||
|
|
||
| const pathFilteringEnabled = (includeOnlyPaths && includeOnlyPaths.length > 0) == true |
Copilot
AI
Aug 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using == true is redundant. The expression (includeOnlyPaths && includeOnlyPaths.length > 0) already returns a boolean.
| const pathFilteringEnabled = (includeOnlyPaths && includeOnlyPaths.length > 0) == true | |
| const pathFilteringEnabled = (includeOnlyPaths && includeOnlyPaths.length > 0) |
Copilot uses AI. Check for mistakes.
| commitInfo: commits | ||
| commits: filteredCommits.length, | ||
| commitInfo: filteredCommits | ||
| .filter(commit => commit.sha) |
Copilot
AI
Aug 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The filter operation commit => commit.sha is applied after path filtering, but commit.sha should always be present in GitHub API responses. This filter may be unnecessary or could indicate a deeper issue.
| .filter(commit => commit.sha) |
Copilot uses AI. Check for mistakes.
This PR adds the ability to filter commits by file paths, enabling better changelog generation for monorepo setups where different applications are stored in separate directories.
Problem
In monorepo environments, users often want to generate changelogs that only include commits affecting specific parts of the codebase. For example, when deploying
app2, they don't want to see commits that only touched files inapp1/. The GitHub API's compare endpoint doesn't support path filtering likegit log -- app1/does.Solution
Added a new optional input parameter
includeOnlyPathsthat accepts comma-separated path patterns:Implementation Details
git log -- <paths>to filter commits directly by path using local git commandsstartsWith()for flexible prefix matching (e.g.,app1/matchesapp1/src/file.js)Changes Made
includeOnlyPathsinput parameter toaction.ymlmain.tsand parameter passing through the call chainOptionsinterface and repository classes to support path filteringGithubRepositoryandGiteaRepositoryTesting
Added unit tests covering:
Existing tests continue to pass, ensuring backward compatibility.
Fixes #1457.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
gitea.com/usr/local/bin/node /home/REDACTED/work/release-changelog-builder-action/release-changelog-builder-action/node_modules/jest-worker/build/workers/processChild.js(dns block)https://api.github.com/graphql/usr/local/bin/node /home/REDACTED/work/release-changelog-builder-action/release-changelog-builder-action/node_modules/jest-worker/build/workers/processChild.js(http block)https://api.github.com/repos/mikepenz/release-changelog-builder-action-playground/compare/1.5.0...2.0.0/usr/local/bin/node /home/REDACTED/work/release-changelog-builder-action/release-changelog-builder-action/node_modules/jest-worker/build/workers/processChild.js(http block)https://api.github.com/repos/mikepenz/release-changelog-builder-action-playground/compare/2.0.0...3.0.0-a01/usr/local/bin/node /home/REDACTED/work/release-changelog-builder-action/release-changelog-builder-action/node_modules/jest-worker/build/workers/processChild.js(http block)https://api.github.com/repos/mikepenz/release-changelog-builder-action-playground/compare/2.0.0...3.0.1/usr/local/bin/node /home/REDACTED/work/release-changelog-builder-action/release-changelog-builder-action/node_modules/jest-worker/build/workers/processChild.js(http block)https://api.github.com/repos/mikepenz/release-changelog-builder-action-playground/releases/tags/1.5.0/usr/local/bin/node /home/REDACTED/work/release-changelog-builder-action/release-changelog-builder-action/node_modules/jest-worker/build/workers/processChild.js(http block)https://api.github.com/repos/mikepenz/release-changelog-builder-action-playground/releases/tags/2.0.0/usr/local/bin/node /home/REDACTED/work/release-changelog-builder-action/release-changelog-builder-action/node_modules/jest-worker/build/workers/processChild.js(http block)https://api.github.com/repos/mikepenz/release-changelog-builder-action-playground/releases/tags/3.0.0-a01/usr/local/bin/node /home/REDACTED/work/release-changelog-builder-action/release-changelog-builder-action/node_modules/jest-worker/build/workers/processChild.js(http block)https://api.github.com/repos/mikepenz/release-changelog-builder-action-playground/releases/tags/3.0.1/usr/local/bin/node /home/REDACTED/work/release-changelog-builder-action/release-changelog-builder-action/node_modules/jest-worker/build/workers/processChild.js(http block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.