Git [submodules] are encoded as commits when walking a Git tree. To
allow the support of them in `radicle-surf`, the tree entry is checked
for this case. The entry will be treated such that it is has a name,
prefix, Oid, and the submodule's URL.
It's important to note that the Oid is not usable within the context
of the repository that is being browsed, since they are entirely
separate.
Instead, the URL should be used in conjunction with the Oid for
browsing purposes outside of `radicle-surf`. However, in a future
iteration it may be considered to be able to browse the local contents
of the submodule, if possible.
N.b. getting the submodule and its URL is not supported for a bare
repository, since it will complain about not having a working tree.
[submodules]: https://git-scm.com/book/en/v2/Git-Tools-Submodules
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Run `niv update` to get the latest Rust toolchain.
This required applying some clippy improvements:
- Removing unnecessary re-export of Oid in `stats` module.
- Replace `get(0)` with `first`
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Update git2 version to 0.18.1 and provide an updated release version
of radicle-git-ext 0.7.0 and radicle-surf 0.18.0.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The current `blob` function is limited to always associating a Blob
with a Commit.
Expose `BlobRef` through a `blob_ref` method, and add useful methods
and serialization to it.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
* sebastinez/add-small-disclaimer-on-diff-commits-fn:
surf: Add a small explainer on binary detection in diffs
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
* sebastinez/add-current-oid-to-filediff:
surf: Add `DiffFile`s to `FileDiff` variants without a diff
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
In some cases a moved file can also be modified and in these cases
there will be a diff as well as new Oid's for the two sides of the
diff.
Add DiffFile to the Moved type, changing the insert_moved method to
accept the DiffFile's and the DiffContent.
When serializing a Moved, if the old and the new are the same then the
serialization of the diff files and content are skipped -- same as the
old behaviour. Otherwise, the two sides are serialized along with the
content.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Update the toolchain to rust-1.72.0. This brought with it a new clippy
check for needless '#'s for string literals. However, this is a false
positive and is being tracked here[[0]].
[0]: https://github.com/rust-lang/rust-clippy/issues/11402
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The homepage and repository fields were out of date. Update them to
the new radicle-git link.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Add features to radicle-git-ext to access the bstr and
percent-encoding features of git-ref-format.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Publish radicle-surf, updating radicle-git-ext and allowing a minicbor
feature flag.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Publish radicle-git-ext to include the following changes:
* Hiding minicbor behind a feature flag
* Fix to commit author's time display/parse
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
* origin/dave/fix-author-timestamp:
git-ext: Display/parse timezone offset in the format git2 expects.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Hide the minicbor feature of git-ref-format behind a minicbor feature
flag in radicle-git-ext.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
git-ref-format-core included the required changes and was missed via
the last publish. Publish the set of crates bumped up to a new semver.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Publish git-ref-format, radicle-git-ext, and radicle-surf with several
additions and bug fixes.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The `Odb::reader` method states:
Note that most backends do not support streaming reads because
they store their objects as compressed/delta’ed blobs. If the
backend does not support streaming reads, use the read method
instead.
This can lead to objects not being found when verifying for
commits. Instead use `read_header` to determine the `ObjectType` of
the `Oid`.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
During the reorganisation of the codebase, the constructors for Token
were removed.
Add back a constructor via the `TryFrom<&'a str>` trait.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
In an attempt to publish radicle-surf, it could not compile due to
git-ref-format supposedly missing.
This is an attempt to publish the git-ref-format family and
radicle-git-ext again in order to try publish radicle-surf.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Adds several methods to Line:
* as_bytes -- gets the underlying bytes
* from_utf8 -- convert the Line to a String
* from_utf8_lossy -- convert Line to Cow<str>
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Updates all crates to the latest git2 version, 0.17.0.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Move git-commit, git-trailers, and link-git to an archived directory
to hide them away -- showing the intent that radicle-git-ext will be
the main crate for git functionality.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Update radicle-git-ext to version 0.3.0 for publishing to crates.io.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The `Oid`s passed into `Commit::new` for parents and tree are never
verified to be commits or a tree, respectively.
Upon `write` of the commit, read the object using the ODB to determine
its type. If its the incorrect object then function fails without
writing to the ODB.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
A vulnerability in a transitive dependency, remove_dir_all, used by
tempfile was found[0].
Update tempfile to 3.4, which does not depend on remove_dir_all.
[0]: https://rustsec.org/advisories/RUSTSEC-2023-0018
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The git-trailers crate depends on parsing logic using nom. This is a
heavy dependency for something that can be done using git2.
Remove the dependency of git-trailers in git-commit and localise the
trailer types -- using git2 to parse the trailers out of the git
commit message.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
* 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
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
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
Previously, there was no way to access the seconds and offset fields
of the Time type.
Add methods for accessing the fields.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
* origin/fix/serialize-tree:
radicle-surf: serialize type for any kind of line
surf: testing an added file
surf: test serialization of tree
surf: fix directory construction
surf: fix path serialization for tree and blob
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
To help frontends with figuring out what kind of line is being talked
about for added and deleted files, the serialization of `Addition` and
`Deletion` always include a type. This mirrors the serialization of
the `Modification` type, which is tagged because it's an enum.
The serialization is hand-rolled since it is desirable to make sure
that added files and deleted files are only ever composed of lines
that are not modified.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Confirm that the serialization of `source::Tree` has the expected
output.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
If a git Tree is a subtree then it no longer contains the path
information while traversing it. The traversal will only carry the
path with it if it does not skip directories, which in the case of
`entries`, it does.
To remedy this, the `path` method is used to pass the information to
`from_entry` instead.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The http-api code expects the 'path' serialized field to be the full
path for trees, tree entries, and blobs, i.e. the path where it is
located concatenated with the name of the entry.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
A placeholder `.expect("TODO")` was left in the diff code while
refactoring.
Change the `expect` to `?` and use the correct `type Error`.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Rust 1.66.0 was announced[0].
The code fixes were all for the clippy warning regarding needless
borrows.
The doc tool now parses for HTML, so any <placeholder> now needs to
be wrapped in backticks, i.e. `<placeholder>`.
[0]: https://blog.rust-lang.org/2022/12/15/Rust-1.66.0.html
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
When deserializing through `serde_json::from_value` the following
error would occur:
panicked at 'called Result::unwrap() on an Err value: Error("invalid
type: string "master", expected a borrowed string", line: 0, column:
0)'
To fix this it is necessary for the Deserialize implementations to
deserialize into an owned String and convert from there.
While attempting to test this the `Qualified` and `Namespaced`
implementations were not able to be used:
error: implementation of `serde::de::Deserialize` is not general enough
--> git-ref-format/t/src/properties/name.rs:86:9
|
86 | roundtrip::json_value(qualified);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `serde::de::Deserialize` is not general enough
|
= note: `Qualified<'_>` must implement `serde::de::Deserialize<'0>`, for any lifetime `'0`...
= note: ...but `Qualified<'_>` actually implements
`serde::de::Deserialize<'1>`, for some specific lifetime `'1`
The Deserialize for both of those types now return owned data by
returning a 'static lifetime instead.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Adds a roundtrip helper for going to/from a json value. This can have
slightly different semantics in comparison to/from a json string.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett