Allow multiple clones and fix job_id address API #133
Merged
+591
−92
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
This PR fixes two related issues and improves sync compatibility:
1. Allow multiple clones of the same repository (#131)
Previously, registering a second local clone of the same remote repository failed with:
Fix: Changed
repos.identityindex from UNIQUE to non-unique. Multiple local clones (e.g.,~/project-mainand~/project-feature) can now coexist with the same identity.2. Fix
roborev addresscommand to use job_id (residual from e956d59)The address command and API were updated to use
job_idinstead ofreview_id, but the daemon client was missed. This caused the refine command and other callers to fail with 400/404 errors.Fix: Updated
daemon.Client.MarkReviewAddressedto sendjob_idinstead ofreview_id, and updated all callers inrefine.goto passreview.JobID.3. Handle duplicate identities in PostgreSQL sync
With multiple clones now allowed, the sync system needed updates to handle ambiguous identity matches.
Example scenario - Two developers collaborating:
Alice's local SQLite (
~/.roborev/roborev.db):Bob's local SQLite (
~/.roborev/roborev.db):Shared PostgreSQL (after both sync):
When Alice pulls Bob's jobs from Postgres:
GetOrCreateRepoByIdentity("git@github.com:org/myapp.git")is calledExample scenario - One developer with multiple clones:
When syncing:
GetOrCreateRepoByIdentity("git@github.com:org/myapp.git")is calledSynced jobs attach to the placeholder (id=3), avoiding ambiguity about which clone they belong to.
Selection logic:
4. Repo display name extraction
Added
ExtractRepoNameFromIdentity()to derive human-readable names:git@github.com:org/repo.git→repohttps://github.com/org/my-project.git→my-projectConfig override available via
sync.repo_namesinconfig.toml.Test plan
TestRepoIdentity/multiple_clones_with_same_identity_allowed- verifies duplicate identities workTestUniqueIndexMigration- verifies old UNIQUE indexes are migratedTestGetOrCreateRepoByIdentity/*- covers all sync selection scenariosTestExtractRepoNameFromIdentity- covers name extraction edge casesTestSyncConfigGetRepoDisplayName- covers config override functionalityTestHTTPClientMarkReviewAddressed- verifies job_id is sentTestMarkReviewAddressedByJobID- verifies storage methodCommits
e6eb6e1- Allow multiple clones (drop UNIQUE constraint, add migration)c4bbaec- Fix daemon client to send job_id instead of review_id69d2b39- Handle duplicate identities in sync with placeholder repos96adb97- Address review findings (nil checks, tests, empty identity handling)d3ba7b5- Prefer single local repo over existing placeholder🤖 Generated with Claude Code