Repository navigation
Description
Summary
Users who downloaded a dataset at v1.0.0 and want v1.0.1 currently have two options: re-clone from scratch (wastes bandwidth for a small metadata change), or manually `git fetch && git merge && git annex get` (error-prone). A `--update` flag on `nemar dataset download` should handle this in one step and pull only the changed annex keys.
Naming note
`nemar dataset update` already exists and means the author-side "push local changes via PR" workflow (`src/commands/dataset.ts:2666`). To avoid confusion, this proposal uses `--update` as a flag on `download`, not a new subcommand. Alternatives considered: `nemar dataset sync`, `nemar dataset pull`. Open for discussion.
Proposed behavior
`nemar dataset download --update` (output dir must exist and be a clone of ``):
- Verify target directory is a git-annex repo for the requested dataset.
- Read local version from `dataset_description.json`.
- `git fetch --tags` and read remote version + available manifest versions via `listManifestVersions`.
- If equal → print "already up to date", exit.
- Fetch both manifests via `getManifest(id, localVersion)` and `getManifest(id, remoteVersion)`, diff the annex keys to compute added / changed / removed files.
- `git merge --ff-only origin/main` — abort with a clear message if non-fast-forward (user has local commits).
- `git annex get <changed_and_added_files>` — only pull the delta, not the whole dataset.
- Removed files: by default, leave local copies in place. Optional `--prune` drops files that no longer exist upstream.
Why this matters
For a 5 GB dataset with a 20 MB metadata bump, `--update` pulls ~20 MB versus a full re-clone's 5 GB. Big win for users iterating on public datasets as they get republished.
Files touched
- `src/commands/dataset.ts` — `download` action
- `src/lib/api.ts` — already has `listManifestVersions` / `getManifest`, should be reusable as-is
- New helper in `src/lib/git-annex.ts` for the manifest-diff pull
Edge cases
- Local has uncommitted changes → refuse, point to `nemar dataset update` (PR workflow) instead.
- Local has committed changes on `main` not on remote → refuse, non-fast-forward merge.
- Manifests not available for local version (older datasets pre-manifest) → fall back to `git annex get` on all annexed files (git-annex will skip anything already present).
Acceptance
- On a v1.0.0 clone after v1.0.1 is published: `nemar dataset download nm000XXX --update` pulls only changed annex keys.
- Running on an up-to-date clone exits cleanly with "already up to date".
- Running with a dirty tree or non-ff local commits is refused with guidance.
Activity
Add --resume, --update, and BIDS entity filters to dataset download (#…