Skip to content

JGitStatusCommand: filter results by fileSet.getFileList() if not empty#1370

Open
piercemar wants to merge 3 commits into
apache:masterfrom
piercemar:feature/jgit_status_fileset
Open

JGitStatusCommand: filter results by fileSet.getFileList() if not empty#1370
piercemar wants to merge 3 commits into
apache:masterfrom
piercemar:feature/jgit_status_fileset

Conversation

@piercemar

Copy link
Copy Markdown

JGitStatusCommand currently ignores fileSet.getFileList() and always returns the full repository status.
This causes inconsistent behavior compared to the gitexe provider, where GitStatusConsumer correctly filters results to only the requested files.

This PR fixes JGitStatusCommand to apply the same file-list filtering, so both providers behave consistently when a FileSet with specific files is supplied.

Testing: This case is not covered by the TCK

I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004

@piercemar

Copy link
Copy Markdown
Author

@michael-o , this is the jgit parallel to SCM-835

@michael-o michael-o self-assigned this Apr 9, 2026
@michael-o

Copy link
Copy Markdown
Member

Is this change covered by the TCK we have?

@piercemar

piercemar commented Apr 27, 2026

Copy link
Copy Markdown
Author

I'm afraid it's not. The TCK for Status command covers only the case where ScmFileSet has no filtering clause.

@slachiewicz slachiewicz added the bug Something isn't working label May 11, 2026
@michael-o

Copy link
Copy Markdown
Member

@kwin Are you OK with this change? I am.

@kwin

kwin commented May 13, 2026

Copy link
Copy Markdown
Member

Looks ok, lets try to add a TCK test for this, but we can do it after the merge.

@piercemar

Copy link
Copy Markdown
Author

Hello @michael-o, @kwin. Are you expecting anything else from my side here ?

if (!fileSet.getFileList().isEmpty()) {
Set<String> fileSetPaths =
fileSet.getFileList().stream().map(File::toString).collect(Collectors.toSet());
changedFiles.removeIf(scmFile -> !fileSetPaths.contains(scmFile.getPath()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The base directory of the fileSet is not necessarily the root directory of the working copy, therefore some file adjustments are necessary before comparing with changedFiles.path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants