Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
A Little Less `git2`
Merged lorenz opened 6 months ago

(I should write up a lengthy description…)

lorenz opened with revision 1cd80447 on base 5caa7b30 +3312 -1624 6 months ago

(I should write up a lengthy description…)

lorenz pushed revision 2 8a36f8ee on base 2e77d5ef +3426 -1618 6 months ago

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:

  1. The crate is refactored to depend on the new crates radicle-git-ref-format radicle-git-metadata, and radicle-oid introduced in the previous commits, instead of radicle-git-ext.
  2. Some code from the radicle-git-ext crate in the radicle-git workspace in repository (rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt) is copied. See crates/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., *oidoid.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}.

lorenz pushed revision 3 8c293dee on base ac572e64 +3325 -1529 6 months ago

Rebase onto spun out patches:

  • 222bc576b7ffb7b9650be00525a1b66087c83b44
  • a1b9d9c92737f12b5b24405042e2432cc9730a5e
lorenz pushed revision 4 8a2ca52a on base 63305904 +3339 -1524 6 months ago

Rebase

lorenz pushed revision 5 01334a94 on base 63305904 +3339 -1524 6 months ago

Linearize

lorenz pushed revision 6 35ede635 on base ea562215 +3005 -1316 6 months ago

Edit commit messages

fintohaps pushed revision 7 af50a863 on base ea562215 +719 -4 6 months ago

REVIEW

lorenz pushed revision 8 deb3610c on base bb68fdad +3197 -1289 6 months ago

Work in Fintan’s feedback, clean up, rebase on top of test fixes.

lorenz pushed revision 9 ae9d102a on base 3e98589a +3200 -1289 6 months ago

Rebase, small fixes to radicle-oid.

lorenz pushed revision 10 e3b93890 on base 292befdb +3199 -1289 6 months ago

Rebase

lorenz pushed revision 11 1707b5d1 on base 292befdb +3199 -1289 6 months ago

Fix wording.

lorenz pushed revision 12 bc04eddf on base 292befdb +3208 -1298 6 months ago

Fix doc-comments.

fintohaps merged revision bc04eddf at efe10f95 6 months ago