(I should write up a lengthy description…)
(I should write up a lengthy description…)
Make git2 an optional dependency of radicle-cob, no dependency
(also not transitively) of radicle-crypto, and refactor radicle to
depend on crates that in turn do not depend on git2
non-optionally.
New Crates
radicle-git-metadata, radicle-git-ref-format, and radicle-oid are
introduced. Refer to their documentation in the respective lib.rs.
Refactoring
The main offending dependency of radicle-cob is radicle-git-ext
from the radicle-git workspace in repository
(rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt) which non-optionally depends on
git2.
So, to achieve removal of this dependency:
- The crate is refactored to depend on the new crates
radicle-git-ref-formatradicle-git-metadata, andradicle-oidintroduced in the previous commits, instead ofradicle-git-ext. - Some code from the
radicle-git-extcrate in theradicle-gitworkspace in repository (rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt) is copied. Seecrates/radicle-cob/src/backend/git/commit.rs.
This cascades to radicle and its dependents.
Firstly, the there is an
impl Deref<Target=git2::Oid> for radicle_git_ext::Oid. This made
it very convenient to just deref to obtain the wrapped git2::Oid,
so there are many expressions of the shape *oid in radicle and
its dependents. However radicle-oid does not provide
impl Deref<Target=git2::Oid> for radicle_oid::Oid, as notably,
Target is an associated type, and not a type parameter, so an
implementation of Deref would tie the new Oid too tightly to a
particular implementation.
Instead, work with impl From<radicle_oid::Oid> for git2::Oid
(which can be enabled using the feature flag radicle-oid/git2).
This explains the changes from *oid to oid.into() at every
transition to “git2 land”.
Secondly, radicle and its dependents are refactored to also depend
on radicle-git-ref-format and (much less prominently)
radicle-git-metadata instead of radicle-git-ext
This is to avoid pulling in git2 via these dependencies.
Thirdly, as the re-exports in crates/radicle/src/git.rs change,
they are at the same time also cleaned up. Notably, the types from
radicle-git-ref-format are re-exported under fmt only, not “twice”.
Also, instead of re-exporting all of git2, the module raw actually
only provides the re-exports required to build the workspace
(potentially breaking dependents outside the workspace, but given just
how many types are re-exported, this seems unlikely) and injects an
extension trait for more ergonomic error handling. Uses of
radicle_git_ext::Error are replaced with uses of the extension trait.
While overall this obviously is very much a breaking change, these
changes should mostly amount to changing from Deref to Into, i.e.,
*oid → oid.into(), importing the extension trait as necessary, and
rewriting imports for radicle::git::fmt. This is indicated by the
mostly mechanical nature of the changes to
crates/radicle-{cli,node,remote-helper}.
Rebase onto spun out patches:
222bc576b7ffb7b9650be00525a1b66087c83b44a1b9d9c92737f12b5b24405042e2432cc9730a5e
Rebase
Linearize
Edit commit messages
REVIEW
Work in Fintan’s feedback, clean up, rebase on top of test fixes.
Rebase, small fixes to radicle-oid.
Rebase
Fix wording.
Fix doc-comments.