71 Commits
Author SHA1 Message Date
Fintan Halpenny 925138577f git2: Update to 0.20 2026-02-18 16:20:16 +00:00
Tom b479768645 surf: fix patchspec handling for directory names using []
Fixes requesting a directory containing another directory with
[brackets] in its name

disable_pathspec_match(true) sets the GIT_DIFF_DISABLE_PATHSPEC_MATCH
flag on libgit2's diff options. Normally, pathspecs are matched using
fnmatch/glob pattern matching, where [ starts a character class, *
and ? are wildcards, and \ is the escape character. With this flag,
pathspecs are treated as literal strings with prefix matching for
directories. So src/[something] matches exactly src/[something] and
any files under it, rather than [something] being interpreted as a
glob character class matching a single character from the set s, o,
m, e, etc.

Removing escaped_name is OK because the old escaped_name doubled
backslashes(\ -> \\) specifically because pathspecs used glob/fnmatch
interpretation, where \ is the escape character. The doubling made
pathspec where \ is the escape character. The doubling made
pathspec treat \\ as "match a literal \". With
disable_pathspec_match(true), there's no glob interpretation at all,
so \ is already treated literally. The doubling is no longer needed
and would actually break things (pathspec would look for \\ instead
of \).

Regarding Windows, escaped_name has no impact on Windows behavior.
On Windows, \ is the path separator and cannot appear in filenames,
so escaped_name was effectively a no-op on Windows anyway. The
existing test for backslash filenames (special/faux\path) is
already gated with `#[cfg(not(windows))]` since such filenames
only exist on Unix. So removing escaped_name has no impact on Windows
behavior.
2026-02-18 16:11:47 +00:00
Fintan Halpenny abcb05a2bd cargo: apply MSRV 1.78.0
Find and apply the MSRV, `rust-version = "1.78.0"` to the
`radicle-git` crates.

While applying this change, use the workspace values to clean up
repetition.
2025-12-08 15:11:21 +00:00
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 30d8275e5f surf: avoid last commit computation on Tree
The computation for getting the last commit that touched a `Tree` can be
expensive. This is avoided when constructing the `Tree` and is moved to a method
on the `Tree` and `Entry`, aptly named `last_commit`.

`Tree::commit` is kept, however, it now refers to the `Commit` that was used
when constructing the `Tree`. This is required to calculate the last commit. It
was also necessary to add the path of the `Tree`.

For adding `Entry::last_commit`, it was necessary to add the path of the
`Entry`. Incidentally, this can be useful for consumers, since just the `name`
would mean that they would have to manually construct the full path.
2025-07-15 17:19:35 +01:00
Fintan Halpenny 527fddfd4d chore: update rust toolchain 1.84
Fixed clippy warnings for lifetime elision and preferring `Display`
implementations over `ToString`.
2025-02-10 14:11:28 +00:00
Fintan Halpenny 224ad08366 Update to git2-0.19
Update the `git2` dependencies to `0.19`, which also allows the uncommenting of
two tests in the `diff` test suite -- as reported by [issue #149][#149].

[#149]: https://github.com/radicle-dev/radicle-git/issues/149

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-06-28 12:08:44 +01:00
Sebastian Martinez 1525ef65f1 git: Rename FileDiff tag from state to status
To be more consistent in the use between state and status on
radicle-interface.
2024-04-25 07:41:47 +02:00
Sebastian Martinez d71b65ab62 git: Update serialization for copied files
Use the same way of serialization of moved files for copied files
2024-04-25 07:41:47 +02:00
Sebastian Martinez dd6bb6fc58 surf: Move FileDiff and Diff serialization to container attributes
To keep the sorting of diffs that is provided by git we should change
the way we serialize them and avoid putting them into separate
modification specific properties.
2024-04-17 11:15:04 +02:00
Fintan Halpenny b4ca7f31db test: improve commit and submodule testing
Two of the tests in radicle-git-ext and radicle-surf relied on using
the Git repository itself. This can end up being an issue when
sandboxing is involved.

This improves the situation by being able to generate commit data to
add to a temporary repository.

It also adds a helper for creating a local, temporary submodule for
testing the submodule interactions in the radicle-surf API.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-03-13 14:22:10 +00: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
Fintan Halpenny 2391c25e95 surf: add submodule support
Git [submodules] are encoded as commits when walking a Git tree. To
allow the support of them in `radicle-surf`, the tree entry is checked
for this case. The entry will be treated such that it is has a name,
prefix, Oid, and the submodule's URL.

It's important to note that the Oid is not usable within the context
of the repository that is being browsed, since they are entirely
separate.

Instead, the URL should be used in conjunction with the Oid for
browsing purposes outside of `radicle-surf`. However, in a future
iteration it may be considered to be able to browse the local contents
of the submodule, if possible.

N.b. getting the submodule and its URL is not supported for a bare
repository, since it will complain about not having a working tree.

[submodules]: https://git-scm.com/book/en/v2/Git-Tools-Submodules

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-03-06 15:59:57 +00:00
Fintan Halpenny d5bf8e7f68 nix: update to rust-1.76
Run `niv update` to get the latest Rust toolchain.

This required applying some clippy improvements:

- Removing unnecessary re-export of Oid in `stats` module.
- Replace `get(0)` with `first`

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-03-05 09:59:12 +00:00
Fintan Halpenny e0b8789b47 git-ext, surf: update git2-0.18.1
Update git2 version to 0.18.1 and provide an updated release version
of radicle-git-ext 0.7.0 and radicle-surf 0.18.0.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-12-04 10:57:39 +00:00
Sebastian Martinez 097d01350d surf: Add stats property to each DiffContent::Plain
This allows us to get the additions and deletions for each file in a
diff.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-10-02 11:29:22 +02:00
Sebastian Martinez 958216084e surf: Add DiffFiles to FileDiff variants without a diff
This allows us to know the blob oid of a moved or copied file, even when
no diff is available.

Also changes the structure of a copied file to be the same as a moved or
renamed file.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-09-21 15:48:56 +02:00
Fintan Halpenny 6ee2815cbf surf: improve Moved type for Diff's
In some cases a moved file can also be modified and in these cases
there will be a diff as well as new Oid's for the two sides of the
diff.

Add DiffFile to the Moved type, changing the insert_moved method to
accept the DiffFile's and the DiffContent.

When serializing a Moved, if the old and the new are the same then the
serialization of the diff files and content are skipped -- same as the
old behaviour. Otherwise, the two sides are serialized along with the
content.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-08-30 17:10:25 +01:00
Fintan Halpenny bc06ee0773 nix: update to rust-1.72.0
Update the toolchain to rust-1.72.0. This brought with it a new clippy
check for needless '#'s for string literals. However, this is a false
positive and is being tracked here[[0]].

[0]: https://github.com/rust-lang/rust-clippy/issues/11402

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-08-30 16:16:29 +01:00
Sebastian Martinez b8def65d6e surf: add simple copy detection to diff
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-06-28 11:31:21 +02:00
Alexis Sellier c47863be76 surf: Add hunk lines ranges 2023-06-22 12:44:30 +02:00
Alexis Sellier 248e23e6cf Add file information to diff
Adds file mode and file OIDs to the file diff.
2023-05-24 17:41:45 +02:00
Fintan Halpenny a8ce42766f meta: update to git2-0.17.0
Updates all crates to the latest git2 version, 0.17.0.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-14 17:07:35 +01:00
Han Xu 59515f68e8 move git-ref-format to under radicle-git-ext
Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-02-21 20:19:30 -08: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
xphoniex bf31d6f636 radicle-surf: Update disabled eof tests to use new methods
Signed-off-by: xphoniex <xphoniex@users.noreply.github.com>
2023-02-08 15:10:10 +00:00
Han Xu 5e7c924fba update docs and add test for commit signature
use crates.io for radicle-std-ext

Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-02-07 01:39:24 -08:00
Han Xu 99732c4fef radicle-surf: fix EofNewLine
- added `NoneMissing` case.
- moved `EofNewLine` into `DiffContent::Plain`.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2023-02-06 20:24:00 -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
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
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
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
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 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
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 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
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
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 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
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 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 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
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
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