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>
- 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>