Commit Graph
171 Commits
Author SHA1 Message Date
Han Xu ec3374c3c9 add CHANGELOG.md
Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-02-06 21:20:04 -08: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
Han Xu 109ca497d4 surf: improvements to Blob
Improve on the previous iteration of `Blob`.

`BlobVec` is simply a `Vec<u8>` underneath, so it is technically not
needed and can be replaced by using `Vec<u8>` directly.

Notice that BlobRef can implement AsRef and Deref for `[u8]`. This
leads to being able to use `T: AsRef<[u8]>` for `Blob` methods and the
`Serialize` implementation.

Apply these two facts and remove any of the remaining code that is no
longer needed.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-02-01 10:21:47 +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
Han Xu 41a2cf5bdc add diff_file method for Repository.
Also refactored `FileDiff` type.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-01-31 09:10:21 -08: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
Han Xu 995855d9b4 Update doc comments.
This patch focuses on the front page of `cargo doc` output.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-01-30 02:58:50 -08:00
Han Xu 9f4dce4ffd change BlobContent to BlobRef that borrows its content from git2::Blob
The motivation is to avoid copying the content bytes that could be
potentially quite large.

Also support Blob<BlobRef>::to_owned() just in case.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-01-29 06:50:11 -08:00
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