Generalize Git URL handling and fix repository creation flow
This commit is contained in:
@@ -691,6 +691,24 @@ Delete `Backend::add_relays` entirely once both call sites are inlined.
|
||||
|
||||
## 9. `create_repository`'s flow is backwards: it inits a mirror, then clones it into the real destination
|
||||
|
||||
> **Status: done.** `Backend::create_repository` now computes `destination`
|
||||
> (`folder.join(dir_name)`) up front and calls `signed_git::init_repository`
|
||||
> directly on it — no mirror path, no `Url::from_file_path`, no `clone_repo`
|
||||
> call, no double `origin` setup. An explicit `destination.exists()` check
|
||||
> (mirroring what `clone_repo` used to guard for free) replaces the removed
|
||||
> clone step's own guard. The push at the end now runs against `destination`
|
||||
> instead of the mirror path, and the task returns `(announcement,
|
||||
> destination)` as before — no caller-visible signature change. This also
|
||||
> dropped `GitStore`/`GitCache::repo_path`/`repo_addr` usage from the
|
||||
> function entirely, since no mirror is created there anymore; `repo_addr`
|
||||
> and `Context as AnyhowContext` became unused imports in `backend.rs` and
|
||||
> were removed. Updated a stale comment in `signed_git`'s
|
||||
> `working_copy_cloned_from_the_mirror_matches_head_and_origin` test, which
|
||||
> referenced this flow by name even though it's a generic `clone_repo`
|
||||
> fixture unrelated to `Backend::create_repository`. `cargo check --workspace`,
|
||||
> `cargo clippy --workspace`, and `cargo test --workspace` (signed_git 67,
|
||||
> signed_state 24, workspace 14) all pass.
|
||||
|
||||
This is a real business-logic flaw, not just a style issue. Today
|
||||
(`backend.rs:437-501`):
|
||||
|
||||
@@ -1046,6 +1064,21 @@ already exists once in the same crate.
|
||||
|
||||
## 15. `Vec<Url>` → `Vec<String>` conversion sprawl — fix the 3 `signed_git` signatures, not the 8 call sites
|
||||
|
||||
> **Status: done.** `try_each_url`, `clone_repo`, `GitCache::ensure_clone`
|
||||
> and `fetch_repo_refs` are now generic over `U: AsRef<str>`. All 7 call
|
||||
> sites (`repo.rs::merge_pull_request`/`clone_to_folder`,
|
||||
> `repo_detail/mod.rs::load_repo`, `new_pull_request.rs::choose_fork` x2,
|
||||
> `pull_request_detail.rs::load`/`clone_urls_of`) now pass the
|
||||
> `Vec<Url>`/`Vec<Url>`-derived value straight through with a plain
|
||||
> `.clone()` of the field, no `.iter().map(ToString::to_string).collect()`
|
||||
> anywhere left in non-test code. One test in `signed_git` passed an empty
|
||||
> untyped `&[]` literal to `fetch_repo_refs`, which lost its type-inference
|
||||
> anchor once the function went generic — fixed with an explicit
|
||||
> `&[] as &[String]` annotation. `cargo check --workspace`,
|
||||
> `cargo clippy -p signed_state -p workspace -p signed_git --all-targets`,
|
||||
> and `cargo test --workspace` (signed_git 67, signed_state 24, workspace 14)
|
||||
> all pass.
|
||||
|
||||
`Announcement::clone` is `Vec<Url>` (`signed_core/src/model.rs`, `Url` being
|
||||
`nostr`'s re-export of the `url` crate's `Url`, `nostr/src/types/url.rs:15`,
|
||||
`pub use url::*;`). Every call site that needs to hand those URLs to
|
||||
@@ -1300,17 +1333,23 @@ method.
|
||||
`latest_grasp_list_servers`.
|
||||
|
||||
Done: see §1. `fetch_events` no longer appears anywhere in the workspace.
|
||||
5. **Generalize the 3 `signed_git` URL-list signatures** to `&[impl AsRef<str>]`
|
||||
5. ✅ **Generalize the 3 `signed_git` URL-list signatures** to `&[impl AsRef<str>]`
|
||||
(§15), then delete the now-redundant `.map(ToString::to_string).collect()`
|
||||
at all 7 call sites. Self-contained to `signed_git`'s public API plus a
|
||||
one-line change per call site; re-run `signed_git`'s existing tests
|
||||
(`clone_repo`/`fetch_repo_refs` already have coverage).
|
||||
6. **Fix `create_repository`'s init/clone ordering** (§9): initialize and
|
||||
|
||||
Done: see §15 for the full list of call sites and verification notes.
|
||||
6. ✅ **Fix `create_repository`'s init/clone ordering** (§9): initialize and
|
||||
push directly at the user's chosen destination, drop the mirror
|
||||
pre-population entirely and let `ensure_clone` populate it lazily like
|
||||
every other repo. Self-contained to one function; verify against this
|
||||
crate's existing `init_repository`/push tests plus a manual
|
||||
create-repository-then-open-detail-view pass.
|
||||
|
||||
Done: see §9. Manual create-repository-then-open-detail-view pass still
|
||||
recommended before shipping, since it depends on the grasp push actually
|
||||
succeeding end-to-end against a live server.
|
||||
7. **Merge `local_repos.rs` and `repo_list.rs` into one file** (§13),
|
||||
keeping both stores as independent entities. Purely organizational, zero
|
||||
call-site changes, safe to do any time.
|
||||
|
||||
Reference in New Issue
Block a user