Commit Graph
100 Commits
Author SHA1 Message Date
Fintan Halpenny 2456fcdb04 Merge remote-tracking branch 'origin/newlines'
* origin/newlines:
  git-commit: remove useless check when converting trailers to string.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-10 13:26:29 +00:00
Fintan Halpenny 4457f12428 Merge remote-tracking branch 'origin/update-doc'
* origin/update-doc:
  update docs and add test for commit signature

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-09 09:48:52 +00:00
Fintan Halpenny 18c4f53421 Merge remote-tracking branch 'origin/radicle-git-ext-bump-version'
* origin/radicle-git-ext-bump-version:
  bump up version for radicle-git-ext

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-08 16:27:57 +00:00
Fintan Halpenny e0358441b9 Merge remote-tracking branch 'origin/git-ref-format-bump-version'
* origin/git-ref-format-bump-version:
  git-ref-format: bump up version and add CHANGELOG.md

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-08 16:26:33 +00:00
Fintan Halpenny f40d5fba06 Merge remote-tracking branch 'origin/changelog'
* origin/changelog:
  add CHANGELOG.md

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-08 16:20:14 +00:00
Fintan Halpenny 5fdccdc8f0 Merge remote-tracking branch 'origin/diff-eof'
* origin/diff-eof:
  radicle-surf: Update disabled eof tests to use new methods
  radicle-surf: fix EofNewLine

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-08 16:19:34 +00:00
Fintan Halpenny aa6459c883 Merge remote-tracking branch 'origin/finto/blob-improvements'
* origin/finto/blob-improvements:
  surf: improvements to Blob

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-03 09:59:07 +00:00
Fintan Halpenny 787818b194 Merge remote-tracking branch 'origin/diff-file'
* origin/diff-file:
  add diff_file method for Repository.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-03 09:58:40 +00:00
Fintan Halpenny e7766d65d8 Merge remote-tracking branch 'han/rm-blob-content'
* han/rm-blob-content:
  change BlobContent to BlobRef that borrows its content from git2::Blob

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-01 10:08:35 +00:00
Fintan Halpenny 748096d570 Merge remote-tracking branch 'han/doc-update'
* han/doc-update:
  Update doc comments.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-01 09:41:00 +00:00
Fintan Halpenny ff3c66e114 Merge remote-tracking branch 'han/error-report'
* han/error-report:
  refactoring the error type of this crate.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-01-30 12:39:46 +00:00
Fintan Halpenny 42302fc5a1 Merge remote-tracking branch 'origin/nix/rust-1.67'
* origin/nix/rust-1.67:
  github: revert toolchain back to stable
  nix: update to rust-1.67

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-01-30 12:38:03 +00:00
Fintan Halpenny 36fb923bd1 github: revert toolchain back to stable
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-01-30 11:01:10 +00:00
Fintan Halpenny 7036923712 nix: update to rust-1.67
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
2023-01-30 11:00:22 +00:00
Fintan Halpenny da2b58b867 Merge remote-tracking branch 'han/remove-object'
* han/remove-object:
  move up blob.rs and tree.rs to src/

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-01-20 08:33:38 +00:00
Fintan Halpenny 640bd9eae5 Merge remote-tracking branch 'han/return-result'
* han/return-result:
  return Result<> instead of Result<Option<>> for find_entry

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-01-18 08:51:30 +00:00
Fintan Halpenny 016ece6647 Merge remote-tracking branch 'han/fix-commit'
* han/fix-commit:
  consolidate object::commit.rs with commit.rs

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-01-12 17:43:22 +00:00
Fintan Halpenny 30e02b756f Merge remote-tracking branch 'han/update-design'
* han/update-design:
  update design doc

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-01-11 10:55:47 +00:00
Fintan Halpenny 502053d972 git-storage: remove pool
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
2023-01-11 10:41:06 +00:00
Fintan Halpenny f3459cdd18 Merge remote-tracking branch 'han/fix-me'
* han/fix-me:
  remove last_commit() in Directory and File.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-01-11 10:19:49 +00:00
Fintan Halpenny 2bb35ed996 Merge remote-tracking branch 'han/del-git'
* han/del-git:
  promote src/git/ files to src/

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-01-06 11:24:37 +00:00
Fintan Halpenny 575d44e8b4 Merge remote-tracking branch 'origin/surf/remove-object-error'
* origin/surf/remove-object-error:
  surf: remove object::Error

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-01-05 10:50:17 +00:00
Fintan Halpenny 1d9ad1ff65 surf: remove object::Error
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
2023-01-04 11:05:37 +00:00
Fintan Halpenny 8d888e80c3 Merge remote-tracking branch 'origin/fix/tree-entry-cmp'
* origin/fix/tree-entry-cmp:
  surf: fix comparison of tree entries

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-01-04 10:59:36 +00:00
Fintan Halpenny 09a423f0d4 surf: fix comparison of tree entries
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
2023-01-03 11:06:53 +00:00
Fintan Halpenny 9be2c3d140 Merge remote-tracking branch 'han/rm-source'
* han/rm-source:
  remove source/ layer and file_system/ layer.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-12-23 09:37:44 +00:00
Fintan Halpenny 824e0d5d9b Merge remote-tracking branch 'origin/surf/revision-stats'
* origin/surf/revision-stats:
  surf: stats for a given revision

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-12-22 14:12:47 +00:00
Fintan Halpenny 5d7b1e4c01 surf: stats for a given revision
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
2022-12-22 12:07:58 +00:00
Fintan Halpenny c2cc44bcc4 Merge remote-tracking branch 'origin/commit/time-accessors'
* origin/commit/time-accessors:
  git-commit: add Time accessors

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-12-22 10:50:18 +00:00
Fintan Halpenny 9f13cd8d07 Merge remote-tracking branch 'han/dogfood'
* han/dogfood:
  refactored Directory, File, Tree and Blob.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-12-22 10:49:38 +00:00
Fintan Halpenny a65ff27e22 git-commit: add Time accessors
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
2022-12-19 15:54:52 +00:00
Fintan Halpenny 79a9472136 Merge remote-tracking branch 'origin/fix/serialize-tree'
* 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>
2022-12-19 11:28:13 +00:00
Fintan Halpenny f4d2e38620 radicle-surf: serialize type for any kind of line
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
2022-12-18 15:04:15 +00:00
Fintan Halpenny 21c0e68ab5 surf: testing an added file
Test the serialization of an added file in a Diff.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-12-16 11:37:59 +00:00
Fintan Halpenny 0d5b6c4c30 surf: test serialization of tree
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
2022-12-16 11:37:59 +00:00
Fintan Halpenny 95c31f2a8e surf: fix directory construction
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
2022-12-16 11:37:58 +00:00
Fintan Halpenny d957f0b1c2 surf: fix path serialization for tree and blob
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
2022-12-16 11:37:58 +00:00
Fintan Halpenny 9df4291616 Merge remote-tracking branch 'origin/nix/rust-1.66'
* origin/nix/rust-1.66:
  surf: missed expect from refactoring diff
  nix: update to rust-1.66

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-12-16 11:37:10 +00:00
Fintan Halpenny 01e2305a41 surf: missed expect from refactoring diff
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
2022-12-16 11:00:16 +00:00
Fintan Halpenny 8d451e3d9d nix: update to rust-1.66
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
2022-12-16 10:54:55 +00:00
Fintan Halpenny 39ce2f9349 Merge remote-tracking branch 'origin/fix/ref-serde'
* origin/fix/ref-serde:
  git-ref-format: fix to deserialization
  test: add roundtrip::json_value

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-12-08 16:04:36 +00:00
Fintan Halpenny db7f2d40e3 git-ref-format: fix to deserialization
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
2022-12-08 15:20:11 +00:00
Fintan Halpenny 9d137e5e7d test: add roundtrip::json_value
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
2022-12-08 15:17:19 +00:00
Fintan Halpenny 1316a13dfc Merge remote-tracking branch 'han/fix-traits'
* han/fix-traits:
  refactoring Revision and ToCommit traits

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-12-06 14:03:16 +00:00
Fintan Halpenny 761e14e7cc Merge remote-tracking branch 'han/doc-comments'
* han/doc-comments:
  Updated docs, include tests in file_system.rs and fix bugs found.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-12-05 10:55:21 +00:00
Fintan Halpenny 858f13f871 Merge remote-tracking branch 'origin/surf/repo'
* origin/surf/repo:
  radicle-surf: refactor repo

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-30 14:22:52 +00:00
Fintan Halpenny 29f2ca337d Merge remote-tracking branch 'origin/surf/diff'
* origin/surf/diff:
  radicle-surf: refactor diff

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-30 14:22:41 +00:00
Fintan Halpenny dab5105eba Merge remote-tracking branch 'origin/surf/source'
* origin/surf/source:
  radicle-surf: remove view
  radicle-surf: remove syntax highlighting
  radicle-surf: rename serialize to serde
  radicle-surf: refactor source objects
  radicle-surf: source module

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-30 14:22:28 +00:00
Fintan Halpenny c06ce205f8 radicle-surf: refactor repo
To have a clear separation of which are public functions and which are
private functions, two `impl Repository` blocks are created.

This lead to some refactoring of names and inclusion of helper
functions, removing the need for the `git2_repo` function.

The `get_commit_stats` function seemed off, since the `Stats` in this
case are to do with the repository. Thus, it does not take a commit
anymore and instead uses the `head` commit to calculate the
repository's `Stats`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-30 13:23:38 +00:00
Fintan Halpenny c316ce8d70 radicle-surf: refactor diff
This is an overhaul of the diff module. The major changes are as
follows.

It shouldn't be possible for an added or deleted file to have any
other kind line changes other than additions or deletions. So there
are now 3 different kinds of changes, Addition, Deletion, or
Modification.

Hunk and Hunks now take a generic type parameter to allow for the
three types of changes. As a consequence a FileDiff does the same.

For the actual file representations, they fill in their parameters as
Addition, Deletion, or Modification.

During this refactor some renaming was also made:
* CreateFile -> Added -- as well as the created field being renamed
to added.
* DeleteFile -> Deleted
* MoveFile -> Moved
* CopyFile -> Copied
* ModifiedFile -> Modified

The Stats are also now carried in the Diff instead of being
calculated. They can be retrieved from the `git2::Diff`.

The final change was to remove the `source::Commit::stats` field in
favour of accessing the `Diff::stats` instead.

The above changes mean that the serialization of `Diff` and `Commit`
are not backwards compatible.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-30 13:23:09 +00:00
Fintan Halpenny c0545f4fac radicle-surf: remove view
The View type is specific to Heartwood and was preemptively defined
when in fact it will not be used. YAGNI.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-30 13:22:44 +00:00
Fintan Halpenny 59d2508392 radicle-surf: remove syntax highlighting
Remove the syntax feature flag and any of the syntax highlighting
logic. This is not required any more from the clients implementation
and so we minimise this codebase in favour of any downstream dependent
to define how they highlight the blob's content.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-30 13:22:44 +00:00
Fintan Halpenny 3284149bd6 radicle-surf: rename serialize to serde
Instead of creating a named feature flag, opt for using the `serde`
package name as the feature flag name. This makes it more clear that
the feature is only enabling serde serialization and nothing else.

This patch also cleans up the testing flags by removing the serialize
flag for testing, as this should just always be tested, and also adds
the syntax flag for future testing.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-30 13:22:44 +00:00
Fintan Halpenny b4d3bf69cf radicle-surf: refactor source objects
Refactor the source data types to reuse existing logic and update to
the latest protocol.

The `Blob` and `Tree` data types are updated to be backed by `File`
and `Directory` respectively. This allows the construction of them to
be much simpler and reuse any existing logic on those types. This also
lead to the removal of `ObjectType` and `Info`.

The `Revision` type was removed in favour of using the `Revision`
trait.

The `Revisions` type was renamed to `View`, while also renaming the
`revision` module to `view`. A `View` is a simple encoding of what a
peer's "view" would look like, i.e. what references do they have. This
also required the introduction of getting free-form categories in the
reference db, i.e. `refs/<category>`, and so a `Categories` iterator
was also introduced.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-30 13:22:44 +00:00
Fintan Halpenny 02321aba7c radicle-surf: source module
This is a straightforward move of all the code source browsing modules
into a module called `source`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-30 13:22:43 +00:00
Fintan Halpenny 5b6b447a96 Merge remote-tracking branch 'origin/surf/infallible-glob'
* origin/surf/infallible-glob:
  radicle-link: refactor glob

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-30 12:53:09 +00:00
Fintan Halpenny 80e1ce3059 Merge remote-tracking branch 'origin/fix/git-commit'
* origin/fix/git-commit:
  git-commit: fix to lack of newline separation

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-30 12:52:09 +00:00
Fintan Halpenny 295b0d25e5 git-commit: fix to lack of newline separation
There was an issue where the trailers were not properly separated from
the commit message itself. In fact, a new line is not added if there
are not trailers either.

Add a fix to add a newline after the commit message. Also adding test
cases to test 0, 1, or 2 trailers in a git commit.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-28 10:07:08 +00:00
Fintan Halpenny d7b5186d8c radicle-link: refactor glob
This patch changes the glob module in a couple of ways, outlined
below.

The first change is the use of PatternString in the constructor
functions. This removes the fallibility of the constructors. This
meant that the tests changed to use the `pattern!` macro instead.

The second change is splitting out the `Glob<Branch>` methods into
`Glob<Local>` and `Glob<Remote>`. This means that the local and remote
globs can be constructed separately, and are then combined via the
`branches` and `and` methods.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-24 12:38:28 +00:00
Fintan Halpenny 0d32904d27 Merge remote-tracking branch 'origin/surf/remove-manual-diff'
* origin/surf/remove-manual-diff:
  radicle-surf: remove diff function

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-24 12:32:57 +00:00
Fintan Halpenny 2061f7777a Merge remote-tracking branch 'origin/surf/organise-tests'
* origin/surf/organise-tests:
  radicle-surf: organise tests

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-24 12:29:49 +00:00
Fintan Halpenny 0ad95dbdfe Merge remote-tracking branch 'origin/std-path'
* origin/std-path:
  radicle-surf: remove file_system::path

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-24 12:29:15 +00:00
Fintan Halpenny b173483fa9 radicle-surf: remove diff function
Remove the `Diff::diff` as it is unused.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-24 12:28:19 +00:00
Fintan Halpenny a4ec9e07e1 radicle-surf: organise tests
Reorganise the tests into module files, rather than all being in a
single file. No tests were changed in this patch.

The `serialize` flag was also not enabled in `test/Cargo.toml`. This
is enabled to ensure those tests are run moving forward.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-24 12:25:31 +00:00
Fintan Halpenny d657572dfd radicle-surf: remove file_system::path
The file_system types, Label & Path, are overengineered. It's more
natural to use the Path and PathBuf types provided by the std library.

This replaces any mention of Label with String and any use of the old
Path with either std::path::Path or std::path::PathBuf, depending on
what kind of ownwership is needed.

Anywhere a "root" directory is needed `PathBuf::new()` is used,
i.e. an empty `PathBuf`. Otherwise `Path::new` can used to pass
directory, or in fact a &str can also be used since it implements
AsRef<Path>.

The `File` and `Directory` types also contain there relative paths,
which can be retrieved while traversing the Tree.

Note the special file name `"special/faux\\path"` requires the use of an
escaping string construction, i.e. `r"special/faux\\path"`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-24 12:08:44 +00:00
Fintan Halpenny 887cdc8010 Merge remote-tracking branch 'origin/directory-generic'
* origin/directory-generic:
  radicle-surf: refactor directory

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-24 12:01:57 +00:00
Fintan Halpenny a549eccd08 radicle-surf: refactor directory
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
2022-11-24 12:01:39 +00:00
Fintan Halpenny aad5f04aef Merge remote-tracking branch 'origin/cargo/clean-up'
* origin/cargo/clean-up:
  meta: clean up cargo dependencies

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-24 11:59:23 +00:00
Fintan Halpenny 9c80fb06a7 meta: clean up cargo dependencies
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
2022-11-24 11:26:32 +00:00
Fintan Halpenny d3115a2215 Merge remote-tracking branch 'origin/git-ref/remove-link-feature'
* origin/git-ref/remove-link-feature:
  git-ref-format: remove link-literals feature

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-21 09:29:04 +00:00
Fintan Halpenny d45d63b7ce git-ref-format: remove link-literals feature
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
2022-11-18 15:45:08 +00:00
Fintan Halpenny 93c13505bb Merge remote-tracking branch 'origin/surf/iter-names'
* origin/surf/iter-names:
  radicle-surf: use specialised iterators for names

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-18 11:33:30 +00:00
Fintan Halpenny d17cb3a8d3 radicle-surf: use specialised iterators for names
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
2022-11-18 11:21:06 +00:00
Fintan Halpenny 08c311b640 Merge remote-tracking branch 'origin/surf/git-ref-namespaces'
* origin/surf/git-ref-namespaces:
  radicle-surf: add short_name methods
  radicle-surf: Namespace using RefString
  git-ref-format: add well-known refspec components
  git-ref-format: fix typo in documentation
  git-ref-format: DoubleEndedIterator for Components
  git-ref-format: add QualifiedPattern and NamespacedPattern

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-18 11:20:30 +00:00
Fintan Halpenny 9f1302649c radicle-surf: add short_name methods
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
2022-11-18 11:20:08 +00:00
Fintan Halpenny 1ac99ac456 radicle-surf: Namespace using RefString
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
2022-11-18 11:13:37 +00:00
Fintan Halpenny 2b5a34a703 git-ref-format: add well-known refspec components
Add constants for well-known refspec component names.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-18 10:49:22 +00:00
Fintan Halpenny a4fc3db933 git-ref-format: fix typo in documentation
Fixes small typo in documentation of `and` function.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-18 10:49:22 +00:00
Fintan Halpenny cf1594cf43 git-ref-format: DoubleEndedIterator for Components
Add DoubleEndedIterator implementations for the two Components
iterators.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-18 10:49:22 +00:00
Fintan Halpenny 6479ba091f git-ref-format: add QualifiedPattern and NamespacedPattern
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
2022-11-18 10:49:22 +00:00
Fintan Halpenny b98c9aac03 Merge remote-tracking branch 'origin/surf/rework-errors'
* origin/surf/rework-errors:
  radicle-surf: reorganise errors

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-18 10:47:49 +00:00
Fintan Halpenny 42093a2fe1 radicle-surf: reorganise errors
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
2022-11-18 10:39:15 +00:00
Fintan Halpenny 0d1bfb89a2 Merge remote-tracking branch 'origin/surf/git-ref-format'
* origin/surf/git-ref-format:
  radicle-surf: rework to use git-ref-format
  radicle-surf: move vcs::git to git
  radicle-surf: remove RefScope
  radicle-surf: remove deny pragma

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-18 10:29:45 +00:00
Fintan Halpenny 9b5ea4352f radicle-surf: rework to use git-ref-format
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
2022-11-18 10:18:11 +00:00
Fintan Halpenny c6c8fe3164 radicle-surf: move vcs::git to git
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
2022-11-18 10:09:43 +00:00
Fintan Halpenny 1649ff3e71 radicle-surf: remove RefScope
RefScope is no longer used, so it's removed.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-18 10:07:21 +00:00
Fintan Halpenny 42a8855dcd radicle-surf: remove deny pragma
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
2022-11-18 10:07:21 +00:00
Fintan Halpenny 46257a8b14 Merge remote-tracking branch 'han/design-update'
* han/design-update:
  redesign Directory and File to be lightweight and lazy.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-18 09:49:21 +00:00
Fintan Halpenny 84d598b4db Merge remote-tracking branch 'origin/qualified-ref-import'
* origin/qualified-ref-import:
  git-ref-format: Component::from_refstr
  git-ref-format: import Qualified within macro

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-16 17:58:07 +00:00
Fintan Halpenny d6c7bb29ab git-ref-format: Component::from_refstr
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
2022-11-16 13:47:22 +00:00
Fintan Halpenny 629191f55a git-ref-format: import Qualified within macro
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
2022-11-16 13:40:48 +00:00
Fintan Halpenny d7fb4ab984 Merge remote-tracking branch 'han/repo-open'
* han/repo-open:
  search parent directories in Repository

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-15 17:00:36 +00:00
Fintan Halpenny 55668e6e0f Merge remote-tracking branch 'han/ref-format'
* han/ref-format:
  Remove Ref, RefGlob and Rev, add Glob that uses git-ref-format.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-09 11:20:57 +00:00
Fintan Halpenny b2d2bd172e Merge remote-tracking branch 'origin/fix/git-commit-trailer'
* origin/fix/git-commit-trailer:
  git-commit: fix for trailer handling

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-04 14:52:01 +00:00
Fintan Halpenny ae4e7bce59 git-commit: fix for trailer handling
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
2022-11-04 14:45:10 +00:00
Fintan Halpenny fefe20343f git-commit: add a description field to Cargo.toml
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-04 12:53:53 +00:00
Fintan Halpenny 1216dd0b42 Merge remote-tracking branch 'origin/git-commit'
* origin/git-commit:
  git-commit: add trailers to Commit
  git-commit: introduce git-commit crate

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-04 12:49:43 +00:00
Fintan Halpenny 9dec69a29a git-commit: add trailers to Commit
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
2022-11-04 12:33:17 +00:00
Fintan Halpenny 8745e46745 git-commit: introduce git-commit crate
Porting the commit code that is found in heartwood[0]. It represents a
parsed git commit object -- sans the id for the commit itself.

[0]: https://github.com/radicle-dev/heartwood/blob/16b22d9178fa6a1aaf2ecb01ec97e067399c5286/radicle/src/git.rs#L392-L575

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-04 12:33:17 +00:00
Fintan Halpenny 7fd402891f Merge remote-tracking branch 'origin/remove-multihash'
* origin/remove-multihash:
  radicle-git-ext: remove multihash and minicbor

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-04 12:32:44 +00:00