Expand description
Shared GitHub owner/repo path derivation (issue #1220).
Why: trusty-mpm’s managed-session workspace root
(~/trusty-mpm-projects/<owner>/<repo>/…) and trusty-memory’s palace-ID
derivation both need the canonical owner/repo identity of a project’s git
origin remote. Centralising the parsing here keeps the two crates in lockstep.
What: Exposes github_path::GithubPath, github_path::parse_github_path
(pure URL parse), and github_path::derive_github_path (reads
remote.origin.url).
Test: cargo test -p trusty-common -- github_path::tests.
Shared GitHub owner/repo path derivation (issue #1220).
Why: two trusty-* subsystems need the canonical owner/repo identity of a
project, derived from its git origin remote: trusty-mpm’s managed-session
workspace root (~/trusty-mpm-projects/<owner>/<repo>/…, #1220) and
trusty-memory’s palace-ID derivation (#1217). Before this module each crate
re-implemented git-URL parsing; centralising it in trusty-common gives both
one tested seam and guarantees they agree on what <owner>/<repo> means for
a given remote. Unlike trusty-memory’s owner_repo_from_git_remote (which
collapses to a single storage-safe owner-repo token), this module keeps
owner and repo as SEPARATE components because #1220 maps them onto two
nested filesystem path segments.
What: [GithubPath] is the parsed { owner, repo } pair; [parse_github_path]
turns a git remote URL into one (pure, no I/O); [derive_github_path] runs
git config --get remote.origin.url in a directory and parses the result
(the only I/O entry point). Both components are slugified for filesystem
safety — lower-cased, non-alphanumerics collapsed to -, trailing .git
stripped — so the result is always two clean path segments.
Test: parse_* unit tests cover SSH/HTTPS, with/without .git, trailing
slashes, nested groups, owner-less and empty inputs; derive_* is covered by
the derive_github_path_reads_origin test against a real temp git repo.
Structs§
- Github
Path - A parsed, slugified GitHub-style project identity.
Constants§
- UNKNOWN_
OWNER - Fallback owner used when a remote exposes a repo segment but no owner.
Functions§
- derive_
github_ path - Derive a
GithubPathfrom the git origin remote of a directory. - parse_
github_ path - Parse a git remote URL into a
GithubPath({ owner, repo }).