Skip to content

Conversation

stefanhaller
Copy link
Collaborator

@stefanhaller stefanhaller commented Sep 28, 2025

The normalisedSelectedNodes function in files_controller.go had a bug where it didn't work correctly for the root item (/). This PR fixes that.

We don't have any tests for this bug. Apparently, the functions that use this (staging and discarding files) also work correctly when they work on a directory and then on the contained file again, that's why nobody has noticed yet. I briefly looked into adding unit tests for the function, but it was more work than I was willing to put into this right now.

@stefanhaller stefanhaller added the maintenance For refactorings, CI changes, tests, version bumping, etc label Sep 28, 2025
Copy link

codacy-production bot commented Sep 28, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 6478bf41 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (6478bf4) Report Missing Report Missing Report Missing
Head commit (302b621) 57757 50202 86.92%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4920) 3 3 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@stefanhaller stefanhaller changed the title WIP Fix normalisedSelectedNodes function Fix normalisedSelectedNodes function Oct 8, 2025
It never changes inside this function, so there's no need to recompute it with
every loop iteration.
The root item's path is ".", and the path of a file at top level is "./file".
When using GetPath, this gives us "." and "file", respectively, and
isDescendentOfSelectedNodes would return false for these.

Working with the internal paths (i.e. without stripping the leading "./") fixes
this.
@stefanhaller stefanhaller force-pushed the fix-normalised-selected-nodes branch from 1045776 to 302b621 Compare October 8, 2025 13:09
@stefanhaller stefanhaller marked this pull request as ready for review October 8, 2025 13:09
@stefanhaller stefanhaller enabled auto-merge October 8, 2025 13:10
@stefanhaller stefanhaller merged commit 60a7d6a into master Oct 8, 2025
12 checks passed
@stefanhaller stefanhaller deleted the fix-normalised-selected-nodes branch October 8, 2025 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance For refactorings, CI changes, tests, version bumping, etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant