Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 4, 2025

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 in app1/. The GitHub API's compare endpoint doesn't support path filtering like git log -- app1/ does.

Solution

Added a new optional input parameter includeOnlyPaths that accepts comma-separated path patterns:

- name: "App1 Changelog" 
  uses: mikepenz/release-changelog-builder-action@{latest-release}
  with:
    includeOnlyPaths: "app1/,shared/"
    fromTag: "v1.0.0"
    toTag: "v2.0.0"

Implementation Details

  • GitHub API approach: For each commit, fetches file changes via additional API calls and filters commits based on whether any changed file matches the specified path patterns
  • Gitea approach: Uses git log -- <paths> to filter commits directly by path using local git commands
  • Path matching: Uses startsWith() for flexible prefix matching (e.g., app1/ matches app1/src/file.js)
  • Backward compatible: Optional parameter that doesn't affect existing functionality

Changes Made

  • Added includeOnlyPaths input parameter to action.yml
  • Updated input processing in main.ts and parameter passing through the call chain
  • Extended Options interface and repository classes to support path filtering
  • Added path filtering logic to both GithubRepository and GiteaRepository
  • Added comprehensive tests for the new functionality
  • Updated README with usage examples and documentation

Testing

Added unit tests covering:

  • Path pattern parsing (comma-separated, whitespace handling)
  • Integration with existing commit filtering
  • Edge cases (empty paths, malformed input)

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
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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
    • Triggering command: /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.

Copilot AI changed the title [WIP] Filtering commits by path Add path filtering support for monorepo setups Jul 4, 2025
Copilot AI requested a review from mikepenz July 4, 2025 11:37
Copilot finished work on behalf of mikepenz July 4, 2025 11:37
@caspervdw
Copy link

@mikepenz I tested this branch and it works as I would expect it to (using Github backend)

@mikepenz
Copy link
Owner

@copilot rebase please

Copy link
Contributor Author

Copilot AI commented Aug 12, 2025

@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.

Copilot finished work on behalf of mikepenz August 12, 2025 05:17
@github-actions
Copy link

github-actions bot commented Aug 12, 2025

TestsPassed ✅SkippedFailed
JUnit Test Report67 ran67 passed0 skipped0 failed
TestResult
No test annotations available

@mikepenz mikepenz requested a review from Copilot August 12, 2025 05:36
Copilot

This comment was marked as outdated.

@mikepenz mikepenz marked this pull request as ready for review August 16, 2025 10:05
Copilot AI and others added 10 commits August 16, 2025 14:13
…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.
@mikepenz mikepenz requested a review from Copilot August 16, 2025 12:20
Copilot

This comment was marked as outdated.

@mikepenz mikepenz requested a review from Copilot August 17, 2025 10:39
Copy link

Copilot AI left a 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 includeOnlyPaths input 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: "",
Copy link

Copilot AI Aug 17, 2025

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.

Suggested change
committerName: "",
committer: commit.committer ?? "",
committerName: commit.committerName ?? "",

Copilot uses AI. Check for mistakes.

authorName: commit.authorName,
authorDate: moment(commit.authorDate),
committer: "",
committerName: "",
Copy link

Copilot AI Aug 17, 2025

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.

Suggested change
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
Copy link

Copilot AI Aug 17, 2025

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.

Suggested change
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)
Copy link

Copilot AI Aug 17, 2025

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.

Suggested change
.filter(commit => commit.sha)

Copilot uses AI. Check for mistakes.

@mikepenz mikepenz merged commit 3429301 into develop Aug 17, 2025
7 checks passed
@mikepenz mikepenz deleted the copilot/fix-1457 branch August 17, 2025 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filtering commits by path

3 participants