Improve on the previous iteration of `Blob`.
`BlobVec` is simply a `Vec<u8>` underneath, so it is technically not
needed and can be replaced by using `Vec<u8>` directly.
Notice that BlobRef can implement AsRef and Deref for `[u8]`. This
leads to being able to use `T: AsRef<[u8]>` for `Blob` methods and the
`Serialize` implementation.
Apply these two facts and remove any of the remaining code that is no
longer needed.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
* han/rm-blob-content:
change BlobContent to BlobRef that borrows its content from git2::Blob
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Rust 1.67 was announced[0].
Update the nix sources to be on par with the latest rustc version.
This required fixes to clippy warnings for using variable
interpolation for format strings.
There was also an advisory error related to libgit2-sys[1], which is
transitively depended on via git2. The fix is included in the 0.16.1
version of git2.
[0]: https://blog.rust-lang.org/2023/01/26/Rust-1.67.0.html
[1]: https://rustsec.org/advisories/RUSTSEC-2023-0003
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The motivation is to avoid copying the content bytes that could be
potentially quite large.
Also support Blob<BlobRef>::to_owned() just in case.
Signed-off-by: Han Xu <keepsimple@gmail.com>
Moved `Error` in `repo.rs` out into a crate level `Error` in `error.rs`.
Repository specific errors are wrapped by the `crate::Error` as well.
Signed-off-by: Han Xu <keepsimple@gmail.com>
There is an advisory error[0] relating to tokio which is transitively
brought in via deadpool.
Since git-storage is not currently used and heartwood is avoiding any
async runtimes, the pool module is removed.
[0]: https://rustsec.org/advisories/RUSTSEC-2023-0001.html
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Users would call Repository::last_commit().
Also renamed "id" to "tree_id" in Directory and "blob_id" in File.
Signed-off-by: Han Xu <keepsimple@gmail.com>
The Error type is no longer used thanks to the clean up of the Tree
and Blob constructions now being exposed through Repository.
Remove the Error type and clean up the imports as a result.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Comparing tree entries would only take into account their names. While
this is useful, it is also useful to compare by their entry kind
first, where trees take precedence over blobs.
A test is added to ensure the ordering is respected. While testing, it
was noticed that the entries aren't sorted when be passed in. When a
`Tree` is constructed it will now sort the entries first, ensure they
are given back in sorted order.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The `stats` method always provided the stats at the `head` of the
repository.
Introduce the `stats_from` method which takes a revision to start
from. `stats` can be defined using `stats_from` and `head`.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett