16 Commits
Author SHA1 Message Date
Fintan Halpenny b570fa1435 Re-License to "MIT OR Aapache-2.0"
The main dependant of `radicle-git`, and its crates, is [`heartwood`].
It is licensed under MIT or Apache-2.0, which has been incompatible with the GPL-3.0 license.
Since the intellectual property of this code base is with the Better Internet Foundation, it was
decided to re-license code in this repository to make the upstream repository compatible.

 - Remove the license headers (and instructions to add them)
 - Add MIT and Apache-2.0 licenses
 - Remove the GPL-3.0 license
 - Change the license declarations in the `Cargo.toml` files

[`heartwood`]: https://app.radicle.xyz/nodes/seed.radicle.xyz/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
2025-11-14 12:52:22 +01:00
Fintan Halpenny f4a958010c fmt: remove .rustfmt.toml
The formatting configuration is not worth the maintenance of a nightly
version. Remove it and allow the default formatting to be used
instead.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-03-13 14:11:36 +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 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 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 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 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
Han Xu c44348fc3c Remove RepositoryRef type and simply use &Repository.
Signed-off-by: Han Xu <keepsimple@gmail.com>
2022-11-24 11:23:42 +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
Han Xu 520c97f03b search parent directories in Repository
- Replace the existing Repository::new() with ::open()
- Add Repository::discover() to support searching parent directories.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2022-11-13 21:17:00 -08:00
Han Xu 97c930cd66 radicle-surf: refactor design: part 4
- Update design doc.
- Refactor History API.
- Use FromRevision and IntoCommit traits.
- Add more test cases.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2022-10-31 22:58:20 -07:00
Han Xu c3d9a2bdc5 refactor design: part 2
- 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>
2022-10-17 19:57:20 -07:00
Han Xu cd9132c377 radicle-surf: an updated design
- A new design document.
- Uses examples/diff.rs to test out some ideas.
- Removes the type Browser.
- Removes the type Snapshot.
2022-10-04 22:01:12 -07:00
Han Xu a111d26047 radicle-surf: convert git2::Oid to radicle_git_ext::Oid
The radicle_git_ext::Oid type has better trait implementations and
should be favoured instead of git2::Oid.
2022-09-26 09:35:49 -07:00
Han Xu 58d69ebf7f copy radicle-surf and radicle-source into this repo.
Signed-off-by: Han Xu <keepsimple@gmail.com>
2022-09-16 22:17:49 -07:00