Commit Graph
64 Commits
Author SHA1 Message Date
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
Han Xu 35b9598a29 Remove Ref, RefGlob and Rev, add Glob that uses git-ref-format.
- Refactored branches(), tags(), namespaces().
- Added filtering for revision_branches().

Signed-off-by: Han Xu <keepsimple@gmail.com>
2022-11-07 14:33:16 -08: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
Fintan Halpenny 0728ee1f66 radicle-git-ext: remove multihash and minicbor
Multihash was deemed as not needed for compatibility since it is
possible to detect a change from SHA1 to SHA256 based on their encoded
lengths. The YAGNI principle is executed and multihash (and minicbor
while we're here) are removed.

This also had an effect on `Urn` which relied heavily on encoding the
value using multihash. The `urn` and `namespace` modules were removed
from radicle-git-types, since they were likely not going to be used
anyway.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-04 12:25:02 +00:00
Fintan Halpenny bf33be9220 Merge remote-tracking branch 'origin/nix/rust-1.65'
* origin/nix/rust-1.65:
  nix: update to rust-1.65

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-04 12:14:38 +00:00
Fintan Halpenny d349b18156 nix: update to rust-1.65
Update to rust-1.65[0].

All hail our new GATs overlord!

[0]: https://blog.rust-lang.org/2022/11/03/Rust-1.65.0.html

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-11-04 11:13:57 +00:00
Fintan Halpenny 7a82c404c4 Merge remote-tracking branch 'han/new-design-4'
* han/new-design-4:
  radicle-surf: refactor design: part 4

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-11-01 08:40:46 +00: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
Fintan Halpenny e913628f0d Merge remote-tracking branch 'origin/trailer-improvements'
* origin/trailer-improvements:
  git-trailers: prepare git-trailers for publishing
  git-trailers: improve usage of OwnedTrailer

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-27 12:45:35 +01:00
Fintan Halpenny c6fe71d2e5 git-trailers: prepare git-trailers for publishing
Prepares git-trailers for publishing to crates.io by adding metadata
to the Cargo.toml.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-10-27 12:33:05 +01:00
Fintan Halpenny ddbdbea932 git-trailers: improve usage of OwnedTrailer
OwnedTrailer was lacking a Debug impl and access to its values.

Add a Debug derivation for OwnedTrailer and OwnedToken. Make token and
values public. Add Deref implementation for OwnedToken.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-10-27 11:46:59 +01:00
Fintan Halpenny ea0afc4993 Merge remote-tracking branch 'origin/storage-tests'
* origin/storage-tests:
  git-storage: add ODB tests

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-24 10:04:48 +01:00
Jorge Iglesias Garcia f6b72dce85 git-storage: add ODB tests
We add tests for ODB functionality, as well as a new `TreeBuilder`
Struct to make building git trees easier (see below).

The `git2::TreeBuilder` can be a pain to use since it has a lifetime
that is tied to the `git2::Repository`. This was causing issues when
trying to write generators for property tests.

Instead, define a custom TreeBuilder which is a defunctionalised list
operations that represent the `insert` and `remove` methods on
`git2::TreeBuilder`.

The implementation of writing a tree then becomes converting the
custom `TreeBuilder` into a `git2::TreeBuilder`.

Signed-off-by: Jorge Iglesias Garcia <me@jorgeig.com>
2022-10-24 16:52:56 +08:00
Fintan Halpenny 7fe6993624 Merge remote-tracking branch 'han/new-design-3'
* han/new-design-3:
  radicle-surf: refactor the design: part 3

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-19 10:32:30 +01:00
Han Xu a4bc76f2ea radicle-surf: refactor the design: part 3
- Detect renames in Diff by default.
- Remove Vcs trait.
- Move `history()` to be a regular method of RepositoryRef.
- Update design doc.

Signed-off-by: Han Xu <keepsimple@gmail.com>
2022-10-18 22:31:38 -07:00
Fintan Halpenny 207b55494e Merge remote-tracking branch 'han/new-design-2'
* han/new-design-2:
  refactor design: part 2
2022-10-18 10:08:39 +01: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
Fintan Halpenny 6a3fac7a4e Merge remote-tracking branch 'origin/publish/git-ext'
* origin/publish/git-ext:
  radicle-git-ext: prepare radicle-git-ext for publishing
  radicle-git-ext: remove link-git dependency
2022-10-14 11:22:20 +01:00
Fintan Halpenny 80d8e0e058 Merge remote-tracking branch 'origin/publish/git-ref-format'
* origin/publish/git-ref-format:
  git-ref-format: prepare git-ref-format crates for publishing
2022-10-14 10:51:48 +01:00
Fintan Halpenny 5eccc79cd8 radicle-git-ext: prepare radicle-git-ext for publishing
It is necessary to specify the version for `radicle-std-ext` in the
`radicle-git-ext` Cargo.toml to publish it to crates.io.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-14 10:49:00 +01:00
Fintan Halpenny 1d41bf0447 radicle-git-ext: remove link-git dependency
link-git is still at an early stage and it's not certain what we will
want to keep out of it, thus publishing it should be avoided.

Remove `link-git` from `radicle-git-ext` for the time being.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-14 10:48:39 +01:00
Fintan Halpenny 1c8a501be1 git-ref-format: prepare git-ref-format crates for publishing
Attempting to publish these crates results in errors that the
`description` field is missing and that the path dependencies do not
specify versions.

Add the `description` and `keywords` fields to `git-ref-format-core`,
`git-ref-format-macro` and `git-ref-format`.

Add the versions for the dependent crates.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-14 10:25:42 +01:00
Fintan Halpenny 4f6284caf5 Merge remote-tracking branch 'origin/namespace'
* origin/namespace:
  git-ref-format: rename namespace functions
2022-10-14 10:05:40 +01:00
Fintan Halpenny daffac4101 git-ref-format: rename namespace functions
The namespace functions can read confusingly:
* `namespaced` - the naming sounds like it is namespacing the input,
when in fact it is ensuring that the input is namespaced.
* `add_namespace` - can be read as adding the namespace to the end of
a ref, when in fact it is placed at the beginning.

Change the naming, respectively, to:
* `to_namespaced` - this uses the conversion naming convention
detailed here[0].
* `with_namespace` - reads as plainly namespacing the ref string.

[0]: https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-13 09:21:53 +01:00
Fintan Halpenny 8d65feb80d Merge remote-tracking branch 'origin/macro/qualified'
* origin/macro/qualified:
  git-ref-format: qualified macro
2022-10-13 09:21:07 +01:00
Fintan Halpenny 339d7fc097 git-ref-format: qualified macro
Add a `qualified!` macro to the set of git-ref-format macros. This
allows the construction of a `refs/<cat>/<name>` reference from a
string literal.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-12 17:00:05 +01:00
keepsimple1 0cec6b5997 Merge pull request #26 from keepsimple1/new-design
radicle-surf: refactoring the design - part 1
2022-10-05 09:17:35 -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
Fintan Halpenny 93d92ede2d Merge remote-tracking branch 'han/test-reorg'
* han/test-reorg:
  radicle-surf: test structure compliance.
2022-09-29 18:00:32 +01:00
Han Xu 0c941740c8 radicle-surf: test structure compliance.
The test structure should be that all tests are gathered under a 't'
sub-crate, followed by the 'test' crate depending on this new crate.
2022-09-29 09:37:54 -07:00
Fintan Halpenny d7b3da88a2 Merge remote-tracking branch 'origin/storage-port'
* origin/storage-port:
  git-storage: remove owner and config
  git-storage: fallible functions for finding objects
  git-storage: return previous targets
  git-storage: port storage from librad
2022-09-27 14:03:05 +01:00
Fintan Halpenny 0730453ac5 git-storage: remove owner and config
The idea of an owner came from radicle-link storing the signer in the
storage which was needed for performing signing when writing
particular rad references. The peer_id and personal identity was also
stored within the monorepo config.

Since git-storage is just general reading & writing of references and
objects, these concepts are not necessarily needed at this
level. Remove the owner from Write and remove the config module.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-09-27 12:32:21 +01:00
Fintan Halpenny ee7a9029ce git-storage: fallible functions for finding objects
When an object does not exist the `find_*` functions will return
None. It will be a common case that users of the API will follow the
pattern of `find_blob(store, oid)?.ok_or(Error::NotFound)`.

Add fallible functions corresponding to each `find_` function
returning a `git2::Error` if the object is not found.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-09-27 12:32:20 +01:00
Fintan Halpenny 5898c0ffde git-storage: return previous targets
The Updated values only tell the updated value of the target. It can
be useful to also return the previous value, e.g. for reporting,
hooks, etc.

Add `Option<Oid>` to the Update::Direct and Update::Symbolic variants.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-09-27 12:32:20 +01:00
Fintan Halpenny e6f36318cd git-storage: port storage from librad
This provides a port of the librad::git::storage[0] API, with a focus
on being more generic and decomposing writing and reading
operations. It also takes heavy inspiration from
link_replication::io::refdb[1] for its implementation of the
transactional writes.

[0]: https://github.com/radicle-dev/radicle-link/blob/master/librad/src/git/storage.rs
[1]: https://github.com/radicle-dev/radicle-link/blob/master/link-replication/src/io/refdb.rs

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-09-27 12:32:20 +01:00
Fintan Halpenny 69e815c124 Merge remote-tracking branch 'origin/generators-port'
* origin/generators-port:
  git-ext/t: Port `gen_oid*` generator methods
2022-09-27 12:32:00 +01:00
Jorge Iglesias 46249f65ba git-ext/t: Port gen_oid* generator methods
Ported from `radicle-link`.

Note that the `Strategy` returns the radicle-git `Oid`type
but it uses `git2::Oid` internally to generate it
since our `Oid` does not expose the `hash_object` and `zero` functions.

Signed-off-by: Jorge Iglesias Garcia <me@jorgeig.com>
2022-09-27 13:04:36 +02:00
Fintan Halpenny b3d23d2019 Merge remote-tracking branch 'han/fix-ci2'
* han/fix-ci2:
  radicle-surf: convert git2::Oid to radicle_git_ext::Oid
  CI: create main branch only if not exist.
2022-09-27 10:17:10 +01: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 a9b3de3f01 CI: create main branch only if not exist.
'git branch -f main' does not work if main was checked out.

Fix: use awk to check if main branch already exists and create if not
exist.
2022-09-23 20:38:38 -07:00
Fintan Halpenny 32902d0174 nix: rust-1.64
rust-1.64 was announced[0].

Update the nix sources to pick up the latest stable. This update
requires some fixes suggested by clippy.

[0]: https://blog.rust-lang.org/2022/09/22/Rust-1.64.0.html

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-09-23 08:45:15 +01:00
Fintan Halpenny 38c84a5958 meta: update to git2-0.15.0
The git2 crate has moved forward and is now at version 0.15.0 while the
dependencies in radicle-git were using 0.13.

Bump the dependencies to version 0.15.0.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-09-22 08:42:30 +01:00
Fintan Halpenny 2ba997727d Merge remote-tracking branch 'han/merge-source'
* han/merge-source:
  fix CI errors on main branch
  merge radicle-source into radicle-surf
2022-09-22 08:33:52 +01:00
Han Xu 4f2962a7e8 fix CI errors on main branch
When CI runs on main branch, the workflow fails to create the "main"
branch as it exists already.

Fix: uses "-f" to force creating "main" branch.
2022-09-21 17:47:11 -07:00