Commit Graph
5 Commits
Author SHA1 Message Date
Jorge Iglesias Garcia f6b72dce85 git-storage: add ODB tests
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>
2022-10-24 16:52:56 +08:00
Fintan Halpenny 0730453ac5 git-storage: remove owner and config
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>
2022-09-27 12:32:21 +01:00
Fintan Halpenny ee7a9029ce git-storage: fallible functions for finding objects
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>
2022-09-27 12:32:20 +01:00
Fintan Halpenny 5898c0ffde git-storage: return previous targets
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>
2022-09-27 12:32:20 +01:00
Fintan Halpenny e6f36318cd git-storage: port storage from librad
This provides a port of the librad::git::storage[0] API, with a focus
on being more generic and decomposing writing and reading
operations. It also takes heavy inspiration from
link_replication::io::refdb[1] for its implementation of the
transactional writes.

[0]: https://github.com/radicle-dev/radicle-link/blob/master/librad/src/git/storage.rs
[1]: https://github.com/radicle-dev/radicle-link/blob/master/link-replication/src/io/refdb.rs

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-09-27 12:32:20 +01:00