This patch applies some refactoring to the directory module. It
applies some renaming and adds some useful methods to the `File` and
`Directory` types.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The aim of this patch is to solve some of the `cargo deny`
warnings. This required updating some dependencies. Some dependencies
of radicle-surf were not used, so they were outright removed.
The last_commit benchmark in radicle-surf is irrelevant as we use more
efficient methods for getting repository histories, so it has been
removed.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Since this package is not intended for radicle-link anymore, the
feature flag and the literals are removed.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The `tag_names` and `branch_names` functions use the `Tags` and
`Branches` functions which require to go through their `TryFrom`
instances. This can be expensive, in the case of `Tags` especially.
Add `TagNames` and `BranchNames` iterators that only return the names
of the tags and branches, respectively.
This requires to change the definition of Revisions, where the
NonEmpty branch list is now foregone and there references are
collected in a BTreeSet to ensure ordering.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Add `short_name` methods to `Branch`, `Local`, `Remote`, and `Tag` to
get the short version of the reference name.
Also adds a `remote` method to `Remote`.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
A `Namespace` is a '/' separated list of components, where each
component represents another level of the namespaces hierarchy. Notice
that a `RefString` is also a '/' separated list of components, thus it
could be reused to define a `Namespace`.
This change uses this observation and reworks `Namespace` to be backed
by a `RefString`.
This naturally leads to defining its helper functions to return
`Namespaced` and `NamespacedPattern` reference names. They are
reworked to take a `Qualified` for regular reference names and
`QualifiedPattern` for refspec names, respectively.
This leads to changing the backing vector of `Glob` to use
`QualifiedPattern` instead of `PatternString`.
While changing `Glob`, it was also noticed that the PhantomData was
not used correctly -- all `impl`s used a generic parameter. This was
changed to use the `Namespace`, `Tag`, and `Branch` types directly,
providing the type-safety that would be expected.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Add constants for well-known refspec component names.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Add DoubleEndedIterator implementations for the two Components
iterators.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
There was no mechanism for building refspec patterns that included
namespaces.
To get around this limitation, QualifiedPattern and NamespacedPattern
are added to the refspec module.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The current `error::Error` type aggregated a lot of different error
scenarios that were not for the actual repo actions, instead they
would be for the domains that the repo actions would return.
This is a reorganisation of those by localising error variants in
their modules:
* namespace::Error
* commit::Error
* glob::Error
* adding `type Error` to ToCommit
* adding `type Error` to Revision
The main Error type now consists of these other Error types and lives
in the `repo` module. It is re-exported at the top-level since
RepositoryRef is the main interaction with the library.
During this refactor, some reorganisation of functions was done as
well:
* Move `get_file` from `Commit` to `RepositoryRef` as
`get_commit_file`.
* Have a blanket implementation of `ToCommit` for any `Revision`,
instead of repeating the implementations.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
The aim of this commit is to better represent the reference names
using git-ref-format.
The first places to change were the Branch and Tag types. For Branch,
the previous types were simply wrappers around the names. They stay
this way, using RefString instead. For Tag, the `name` field is
replaced with RefString.
Note: The parsing logic becomes easier here by utilising the
Namespaced and Qualified types.
The consequences of these changes meant that areas that used
BranchName or TagName are changed to use RefString.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Other VCS systems are no longer expected to be supported.
Remove the git hierarchy up to the top-level and remove the vcs
hierarchy.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
This pragma gets in the way more than it solves anything.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
Improve Component::from_refstring by redefining it as
Component::from_refstr. This allows the use of `RefStr` or `RefString`
instead of just RefString.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
If the `qualified` macro was used, the compiler would complain that it
required an import of `Qualified`.
Fixed by importing Qualified within the unsafe block of the definition
of `qualified`.
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
- Added Oid into Directory and File.
- Moved file content and directory content out into their own.
- Lazily load directory content on-demand.
- Take advantage of git2::tree to retrieve an entry on-demand.
Also added a new example for browsing.
Signed-off-by: Han Xu <keepsimple@gmail.com>
- Replace the existing Repository::new() with ::open()
- Add Repository::discover() to support searching parent directories.
Signed-off-by: Han Xu <keepsimple@gmail.com>
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>