If a Commit was constructed with trailers, they would not be added to
the buffer for committing.
Fix this by parsing the message by inspecting each line for a
potential trailer, if there is one then store it for later, otherwise
keep it as part of the message. This means that a message stays intact
even if a trailer that is expected to parse did not.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Add git trailers to the data of the Commit.
For convenience, git2 is used to extract the git trailers and they are
then converted to `OwnedTrailer`.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Multihash was deemed as not needed for compatibility since it is
possible to detect a change from SHA1 to SHA256 based on their encoded
lengths. The YAGNI principle is executed and multihash (and minicbor
while we're here) are removed.
This also had an effect on `Urn` which relied heavily on encoding the
value using multihash. The `urn` and `namespace` modules were removed
from radicle-git-types, since they were likely not going to be used
anyway.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
- Update design doc.
- Refactor History API.
- Use FromRevision and IntoCommit traits.
- Add more test cases.
Signed-off-by: Han Xu <keepsimple@gmail.com>
Prepares git-trailers for publishing to crates.io by adding metadata
to the Cargo.toml.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
OwnedTrailer was lacking a Debug impl and access to its values.
Add a Debug derivation for OwnedTrailer and OwnedToken. Make token and
values public. Add Deref implementation for OwnedToken.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
We add tests for ODB functionality, as well as a new `TreeBuilder`
Struct to make building git trees easier (see below).
The `git2::TreeBuilder` can be a pain to use since it has a lifetime
that is tied to the `git2::Repository`. This was causing issues when
trying to write generators for property tests.
Instead, define a custom TreeBuilder which is a defunctionalised list
operations that represent the `insert` and `remove` methods on
`git2::TreeBuilder`.
The implementation of writing a tree then becomes converting the
custom `TreeBuilder` into a `git2::TreeBuilder`.
Signed-off-by: Jorge Iglesias Garcia <me@jorgeig.com>
- Detect renames in Diff by default.
- Remove Vcs trait.
- Move `history()` to be a regular method of RepositoryRef.
- Update design doc.
Signed-off-by: Han Xu <keepsimple@gmail.com>
- Add a code browsing test
- Update design doc, mainly Code Browsing and Diff.
- Simplify `Directory`.
- Remove `Tree` and `Forest`, and `SystemType`.
- Use `Rev` in `diff()`.
Signed-off-by: Han Xu <keepsimple@gmail.com>
It is necessary to specify the version for `radicle-std-ext` in the
`radicle-git-ext` Cargo.toml to publish it to crates.io.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
link-git is still at an early stage and it's not certain what we will
want to keep out of it, thus publishing it should be avoided.
Remove `link-git` from `radicle-git-ext` for the time being.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Attempting to publish these crates results in errors that the
`description` field is missing and that the path dependencies do not
specify versions.
Add the `description` and `keywords` fields to `git-ref-format-core`,
`git-ref-format-macro` and `git-ref-format`.
Add the versions for the dependent crates.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
The namespace functions can read confusingly:
* `namespaced` - the naming sounds like it is namespacing the input,
when in fact it is ensuring that the input is namespaced.
* `add_namespace` - can be read as adding the namespace to the end of
a ref, when in fact it is placed at the beginning.
Change the naming, respectively, to:
* `to_namespaced` - this uses the conversion naming convention
detailed here[0].
* `with_namespace` - reads as plainly namespacing the ref string.
[0]: https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Add a `qualified!` macro to the set of git-ref-format macros. This
allows the construction of a `refs/<cat>/<name>` reference from a
string literal.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
The idea of an owner came from radicle-link storing the signer in the
storage which was needed for performing signing when writing
particular rad references. The peer_id and personal identity was also
stored within the monorepo config.
Since git-storage is just general reading & writing of references and
objects, these concepts are not necessarily needed at this
level. Remove the owner from Write and remove the config module.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
When an object does not exist the `find_*` functions will return
None. It will be a common case that users of the API will follow the
pattern of `find_blob(store, oid)?.ok_or(Error::NotFound)`.
Add fallible functions corresponding to each `find_` function
returning a `git2::Error` if the object is not found.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
The Updated values only tell the updated value of the target. It can
be useful to also return the previous value, e.g. for reporting,
hooks, etc.
Add `Option<Oid>` to the Update::Direct and Update::Symbolic variants.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Ported from `radicle-link`.
Note that the `Strategy` returns the radicle-git `Oid`type
but it uses `git2::Oid` internally to generate it
since our `Oid` does not expose the `hash_object` and `zero` functions.
Signed-off-by: Jorge Iglesias Garcia <me@jorgeig.com>
The git2 crate has moved forward and is now at version 0.15.0 while the
dependencies in radicle-git were using 0.13.
Bump the dependencies to version 0.15.0.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>