308 Commits
Author SHA1 Message Date
keepsimple1 48022590d0 Merge pull request #104 from keepsimple1/empty-branch-test
radicle-surf: fix history path filter for empty path
2023-01-28 10:20:58 -08:00
Han Xu 755124dab3 fix history path filter for empty path
- add script to update git-platinum
- use Rust 1.66.1 for lint to postpone the move to 1.67.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-01-24 20:26:58 -08:00
Han Xu 80f8f64e5f refactoring the error type of this crate.
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>
2023-01-24 07:29:55 -08: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
Han Xu 88e6f0c94c move up blob.rs and tree.rs to src/
Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-01-18 09:25:50 -08: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
Han Xu de418e811e return Result<> instead of Result<Option<>> for find_entry
Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-01-17 08:42:35 -08: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
Han Xu 9bcbfca062 update design doc 2023-01-07 23:37:28 -08:00
Han Xu 83b95d6928 remove last_commit() in Directory and File.
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>
2023-01-07 14:27:44 -08:00
Han Xu 6bb9670abc consolidate object::commit.rs with commit.rs
Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-01-07 13:05:32 -08: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
Han Xu 60596232da promote src/git/ files to src/
Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-01-05 19:19:14 -08: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
Han Xu 4e373fb8de remove source/ layer and file_system/ layer.
- Merge `person.rs` into `object/commit.rs`.
- Move `source/commit.rs` into `object/`.
- Merge `file_system/directory.rs` into `file_system.rs`.
- Rename `file_system.rs` to `fs.rs`.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2022-12-21 13:32:19 -08:00
Han Xu 922206e08e refactored Directory, File, Tree and Blob.
Signed-off-by: Han Xu <keepsimple@gmail.com>
2022-12-21 03:15:28 -08: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
Han Xu a16a627151 refactoring Revision and ToCommit traits
- Added a generic impl for &Revision
- Updated ToCommit for easier usage.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2022-12-05 21:07:56 -08: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
Han Xu 6100b12006 Updated docs, include tests in file_system.rs and fix bugs found.
Signed-off-by: Han Xu <keepsimple@gmail.com>
2022-12-04 19:46:52 -08: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