Repository navigation
Phase 2: Fix git-divergence on OpenNeuro re-import - #994
Merged
neuromechanist merged 2 commits intoJul 22, 2026
Merged
neuromechanist merged 2 commits into
neuromechanist merged 2 commits into
Conversation
Re-importing an OpenNeuro dataset onto an already-published nemarDatasets repo always makes a fresh clone whose main shares no metadata history with origin. Step 6's new metadata commit then collides with the first import's metadata commit on push, and pushToGitHub's rebase hard-fails with "diverging commits and auto-rebase failed". Add Step 4c: after the git-annex branch merge (Step 4b) and before the S3 remote setup (Step 5), fetch origin/main and, only on a plain main branch with a resolvable origin tip, reset local main onto it. Detached HEAD and git-annex adjusted branches are excluded since pushToGitHub already special-cases them. First imports (no origin main yet) are unaffected. Scoped to same-version recovery; a genuinely new upstream snapshot is out of scope. decideReimportMainReset is the pure gate, unit-tested directly. git-annex-remote.test.ts adds a real bare-repo regression guard that reproduces the diverging-push failure, plus a fix test proving the Step 4c sequence turns the same re-import into a fast-forward push.
Two real bare-repo tests reviewers flagged as missing coverage: - Same-version recovery (the primary #967 use case): re-import with metadata content identical to the first import is a no-op commit and a no-op push, not an error. - First-import regression guard: origin has no main ref yet, so Step 4c's fetch fails and the block is skipped entirely, leaving the ordinary first-import push untouched. Also references the tracked follow-up (#993) for new-version drift detection in the Step 4c out-of-scope comment.
neuromechanist
merged commit Jul 22, 2026
8d379c8
into
feature/issue-989-epic-import-stability
1 check passed
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-importing an OpenNeuro dataset onto an already-published nemarDatasets repo failed at
prepare: a fresh OpenNeuro clone'smaindiverges from origin/main (each import adds its own metadata commit on the same files), sopushToGitHub's rebase conflicts and hard-fails 'diverging commits and auto-rebase failed'. This blocked re-copying the 14 quarantined #967 recovery stragglers.Fix: new Step 4c in
prepareImport(src/lib/import-openneuro.ts) — on a re-import (origin/main resolves + current branch ismain),git fetch origin main+git reset --hard origin/mainBEFORE the metadata seed, so the seed is idempotent / fast-forward and the push succeeds. PuredecideReimportMainResetguards out detached-HEAD and adjusted/* (DataLad) branches. First-import path (origin has nomain) is a fully-skipped no-op.pushToGitHub's rebase is untouched (stays as the backstop for genuine concurrent-push divergence). The data copy phase is server-side S3 by annex key, independent ofmainhistory.Same-version assumption (recovery use case) is documented; a genuinely new upstream snapshot is out of scope, tracked as a drift-guard follow-up #993.
Test plan
Real (no-mock) local-git tests via the existing bare-repo harness:
decideReimportMainResetpure unit (5 cases: sha+main, null, empty-string, adjusted/main, HEAD).Verified locally: root tsc + Biome clean; CI pure-tier 2504 tests, 0 fail. Two Sonnet reviewers, no blocking findings (drift-guard deferred to #993).
Closes #990
Part of epic #989