Skip to content

Conversation

@mvdoc
Copy link

@mvdoc mvdoc commented Jan 27, 2026

I typically save derivatives as nested submodules/datalad datasets. I was uploading a dataset and noticed that the openneuro CLI was correctly skipping the parent .git folder but not the derivatives/.git. This could cause the CLI to upload duplicate annex objects as regular files when uploading datasets containing git-annex submodules.

This fix creates a new shouldIncludeFile() function to extract the inclusion logic, adding a check for dot files anywhere in the relative path. It also adds unit tests for the new shouldIncludeFile() function.

Previously, the upload command only skipped files starting with "."
which correctly skipped root hidden files (.git/, .datalad/, etc.) but
not hidden files/dirs in submodules (e.g., derivatives/.git/annex/objects/
or derivatives/.datalad/config).

This could cause the CLI to upload duplicate annex objects or internal
datalad files when uploading datasets containing submodules.

The fix adds a check for any hidden path component (starting with .)
anywhere in the relative path, while still correctly following symlinks
that point to .git/annex/objects/.

Also adds unit tests for the new shouldIncludeFile() function.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings January 27, 2026 01:56
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 fixes a bug where the OpenNeuro CLI was not skipping .git directories in submodules (e.g., derivatives/.git), which could cause duplicate git-annex objects to be uploaded as regular files. The fix extracts file filtering logic into a new shouldIncludeFile() function that checks for hidden files/directories anywhere in the relative path, not just at the root level.

Changes:

  • Added hiddenPathPattern regex and shouldIncludeFile() function to properly filter hidden files in subdirectories
  • Refactored addGitFiles() to use the new filtering function
  • Added comprehensive unit tests covering various scenarios including root-level hidden files, submodule hidden files, and edge cases

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cli/src/commands/upload.ts Added hiddenPathPattern regex and shouldIncludeFile() function to detect and exclude hidden files/directories in submodules; refactored addGitFiles() to use new filtering logic
cli/src/commands/upload.test.ts Added comprehensive unit tests for hiddenPathPattern regex and shouldIncludeFile() function covering regular files, hidden files at root, hidden files in submodules, and edge cases

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant