Commit Graph

804 Commits

Author SHA1 Message Date
Arnaud Bailly 0ecdc76422
cli: Improve `rad node logs` error message
If the rad node is spawned by systemd there won't be any logs file
to read and `rad node logs` command will fail with the standard
error message from fs.
2024-11-27 10:19:04 +01:00
cloudhead 3ad84420bd
cli: Implement `rad cob migrate`
Adds the new `migrate` sub-command to migrate the COB database.
Checks for version when opening the COBs database and suggests the
command on out of date version.

Also adds the 2nd migration to the COBs cache, which updates the patch
JSON schema.
2024-11-22 21:27:45 +01:00
cloudhead cab56c1113
helper: Use the correct head when merging a patch
Fixes a bug where the wrong head would be used as part of the merge
action.

Use the head of the revision instead of the head of the canonical
branch.
2024-11-18 16:10:13 +01:00
Fintan Halpenny 91914d9345
radicle: improve quorum copy
The `no quorum found` error can be opaque and lead to a lot of confusion. It is
better to give more information for this error so that it leads to easier
debugging, since it can be quite a common warning/error.

Instead of a single error, there are two cases provided: `NoCandidates` and
`Diverging`, to capture the two different variants of errors that can occur.

`Display` implementations are provided for both to provide more information.
2024-11-18 12:32:44 +01:00
Fintan Halpenny e412168be3
node: do not fail on `set_head`
The failure to set a HEAD ref, due to quourum, during a fetch should not fail
the fetch entirely.

Instead, log the success and failure, or return an error in other cases.

In fact, any failure to set the head could have resulted in notifications not
being sent, nor caching to occur.
2024-11-18 12:32:40 +01:00
cloudhead 6c8ee4330e
radicle: Implement migration callback mechanism
Add the ability to have native migrations and progress callback
functions in migration code for the COB cache.
2024-11-14 17:21:33 +01:00
Fintan Halpenny ccc0297b5a
cli: test deletion via `git push -d`
Ensure that remote branches can be delete via the `-d` flag. This
includes the fact that one can delete the `refs/heads/patches`
branches, as long as they are owned by the current operator.
2024-11-11 12:00:45 +01:00
Fintan Halpenny 43e08a8e70
cli: rad id update --edit
Introduce an `--edit` option to `rad id update` to allow a user to open up their
text editor for changing the document's contents.
2024-11-11 11:58:09 +01:00
Fintan Halpenny c6d975799a
cli: verification of project for json errors only
An `xyz.radicle.project` payload is allowed to not be defined, so report the
error if the project resulted in a JSON error.
2024-11-11 11:58:09 +01:00
Fintan Halpenny 0d402647cb
term: allow Editor to be reusable
The `Editor` is very useful for correctly opening a text editor and making changes
to some initial input. The current use of `Editor` is only for getting input for
commets.

However, it would also be useful for opening up a text editor on some other
existing files or text, for example, in the command `rad config edit`.

The `Editor` struct was changed to have two new options, `truncate` and
`cleanup`, to allow the user of the struct to dictate whether existing text is
truncated, and if the underlying file should be remove.

The original `new` method is now named `comment`, mimicing the existing
construction of a temporary `RAD_COMMENT` file.

The new version of `new` accepts any file for the `Editor` and will open it
without truncating or removing the file.

`Editor` is now used for the `rad config edit` command.
2024-11-11 11:27:33 +01:00
Fintan Halpenny 23f8cf0d84
cli: Option for caching COBs for all repositories
To make it easier for caching COBs across all the repositories in storage, add
an option `--storage` that iterates over all the repositories and performs the
cache operation for each.
2024-11-07 16:56:38 +01:00
Lars Wirzenius df44cee9ef
cob: Add an experimental "job" COB
This is meant to record in Radicle that automated "jobs" have been run
on a repository. The job might be, for example, a CI run that builds
the software and runs its tests. The recording is done in a "job COB",
which can be in three states:

* fresh -- when the job has been triggered, but has not yet started running
* running -- when it's running
* finished -- when it's finished running

The finished state also records whether the job was successful or if
it failed.

A job COB records the git commit that it runs on, and the "run ID" of
the job. The run ID represents an external identifier, such as one
assigned by a remote CI system. The COB can optionally store a URL
related to the job, such as to the build log from CI.

Add the "rad job" subcommand to create and manage job COBs. For
production use, the COBs should be created and updated using
`heartwood` as a library instead of running "rad job", if at all
possible. However, "rad job list" lists the jobs that have been run on
the repository.

The COB type name is xyz.radicle.beta.job, until we've gained
experience with the COB and its implementation and are ready to
declare it stable.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-11-06 17:26:00 +01:00
cloudhead f6aa46a283
cli: Try to connect to seeds specified as options
When fetching with a `--seed` specified on the CLI, try to connect to it
if not already connected.
2024-11-05 12:18:12 +01:00
Johannes Kuehlewindt 0c9a7419dc
cli: Add config modification sub-commands
Adds `set`, `add`, `remove`, `delete` to `rad config`.

Note that the changes will affect the configuration file, but not the
running instances. For changes to be reflected in the running instances
the node would need to be restarted.
2024-10-23 17:19:27 +02:00
cloudhead a838c3ea01
fmt: Run `cargo fmt` 2024-10-23 16:17:24 +02:00
Fintan Halpenny de1958fab0 radicle: refactor doc
The aim of this change is to make the `Doc` type more safe to use by approaching
the design via [Parse don't validate][[0]] approach.

The problem with the previous approach was that all field were `pub` and thus a
`Doc<Verified>` could easily be mutated and serialized. Granted, the code that
used the serialization would tend to verify the `Doc` first, however, this
approach *ensures* that only a verified `Doc` can be serialized. It also meant
that trying to add new data that would follow the parse approach would require
more generic parameters on top of the existing `PhantomData` parameter, i.e. we
need to do something like: `Doc<RawField, V> -> Doc<ValidField, V>`.

The new approach splits the type into two separate types: `RawDoc` and `Doc`.
The former is allowed to be mutated at will, and uses types that are less
strict. The latter is the valid type that can only be constructed by validating
a `RawDoc` (or the `initial` constructor). The `Doc` type's fields can then only
be accessed by read-only methods.

Solves the problems above by only allowing mutations to `RawDoc`, as well as,
new fields being added to `RawDoc` which are then validated via
`RawDoc::verified`.

[0]: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-validate/
2024-10-22 14:58:12 +01:00
cloudhead 989edacd56
Include new `rad/root` in signed refs
We ensure that a `rad/root` ref is included in the signed refs file
under `rad/sigrefs` for all remotes. This prevents a certain kind of
"grafting" attack where signed refs can be copied between repositories,
by having the peer sign over the identity root together with the data refs.

When verifying signed refs, we ensure that the ref is present and points
to an identity branch root that matches the repository identity containing
the signed refs.

Alternatives: lots of alternatives were considered, but this one doesn't
introduce any changes to the signing. The `rad/id/root` name was
considered but is invalid due to `rad/id`.
2024-10-21 16:32:49 +02:00
Fintan Halpenny 46c2637f77
radicle: add tags fetch refspec
Add a fetch refspec to fetch tags from a Radicle remote. The
`--no-tag` option is also included. This is to ensure that it is easy
to collaborate by having tags placed in the remote namespace of
another peer. However, if the namespace is the default `rad` remote,
then tags are expected to be allowed -- this is to pave way for the
feature of canonical tags.

In the tests, the `--tags` option is removed -- and is generally
recommended that it is not used. This is to ensure that it does not
override the `--no-tag` option.
2024-10-21 14:30:37 +02:00
cloudhead 855327d303
cob: Change APIs to take URIs for embeds
To facilitate edit actions, take URIs instead of the actual blobs. This
means API callers don't have to load all the blobs just for them to be
re-hashed when an edit action is submitted.

There are some peculiarities when dealing with the `Identity` COB since
the embed is the identity document itself. We handle that special case.
2024-10-14 12:51:36 +02:00
Alexis Sellier 729a6e057e
cobs: Fix COB drafts to work correctly 2024-10-01 15:59:23 +02:00
Fintan Halpenny e130b4dc06
radicle: custom upstream remote for patches
When creating a new upstream for the patch workflow, the remote name is always
assumed to be `rad`.

It's possible for users to use another remote name but still use a `rad://` URL
for pushing. To allow for this, the function that creates the upstream entry now
takes a remote name. In the remote helper, `rad patch checkout`, and `rad patch
set` the remote can be optionally specified and fall back to the `rad` remote
name as a default.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-09-12 17:59:57 +02:00
cloudhead bde68ac76c
Update `radicle-cli` crate to 0.11.0 2024-09-03 12:33:02 +02:00
cloudhead 2d241e5f7d
Update `radicle-crypto` crate to 0.11.0 2024-08-28 13:01:35 +02:00
cloudhead c112f3fbc9
Update `radicle-cob` crate to 0.12.0 2024-08-28 12:55:30 +02:00
cloudhead c8fbcf2a7a
helper: Revert patches correctly
When pushing to the default branch and updating the canonical head,
check to see if any merged patches are reverted due to this change.

If so, make sure the COB cache reflects this.
2024-08-23 15:59:59 +02:00
Sebastian Martinez c0aecbac3a
Relax version requirement for `radicle` dependencies
Since a few crates rely on the `radicle` crate, dependency updates that
affect multiple crates like `git2` are not able to resolve the
dependencies and fail, if the version is fixed to e.g. `0.12.0`
2024-08-20 16:35:04 +02:00
Sebastian Martinez beac367056
Update `radicle-surf` to 0.22.0 2024-08-20 16:35:04 +02:00
Sebastian Martinez cae66b6168
Update `radicle-git-ext` to 0.8.0 2024-08-20 16:35:04 +02:00
Fintan Halpenny eb432b9bc1
cli: announce on issue edit and comment
The `rad issue edit` and `rad issue comment` subcommands were not included in
the announce check. Since these are considered write commands, they should also
announce when executed.
2024-08-20 16:32:02 +02:00
Fintan Halpenny e1470fccd7
fetch: update gix-pack and gix-odb
The `gix-fs` crate was flagged as vulnerable[^0]. To update it to `>=0.11.0`, it
was necessary to update the `gix-pack` and `gix-odb` crate versions to `0.51`
and `0.61`, respectively.

This in turn updated `fastrand` which changed its algorithm[^1], which meant
that some test outputs were reordered or matched new values.

[0]: https://rustsec.org/advisories/RUSTSEC-2024-0350
[1]: https://github.com/smol-rs/fastrand/blob/master/CHANGELOG.md#version-210
2024-08-09 12:41:01 +02:00
cloudhead bfc949d094
cli: Log errors when COBs can't load 2024-08-09 10:47:54 +02:00
cloudhead 73f3c49689
cli: Don't fail on `rad ls` if project is invalid 2024-08-07 10:40:46 +02:00
cloudhead a496190198
cli: Suggest the user to reset the cache
If there is an error loading a patch or issue, suggest resetting the
cache.
2024-08-06 14:43:59 +02:00
cloudhead c6a8a00055
Update `rust-toolchain` to 1.80
Fix new clippy warnings.
2024-08-06 14:37:21 +02:00
Fintan Halpenny 52554af4f1
cli: add `rad unblock` command
Add the `rad unblock` command for reversing the effect of blocking an NID or RID.

In both cases, the entry is removed from the DB, if the policy was set to block
-- otherwise it is a no-op.
2024-08-06 14:12:44 +02:00
Ivan Stanković 468d5a46ee
cli: Only get the signer where needed in `rad id`
Requesting a signer may prompt the user for key password, which
is not really needed with commands like `list` and `show`.
2024-08-06 14:02:46 +02:00
cloudhead 84e3ba1482
Validate project names properly in all places
We were only validating names when passed as a flag to `rad init
--name`.
2024-07-31 16:05:31 +02:00
cloudhead ee1c867800
cli: Add way to init from existing repositories
This adds an option to `rad init` to initialize a working copy with
an existing radicle repository in storage:

    rad init --existing <rid>

This sets up the remote(s) and configures the repo for you.
2024-07-29 11:49:19 +02:00
cloudhead 74336f961a
cli: Write comments into draft patch review
We tidy things up with an explicit `Brain` type that stores the accepted
state of the code.

Review comments are added to the patch draft.
2024-07-24 16:46:24 +02:00
cloudhead 7cecabed42
Add `id` to `Revision`, forbid duplicate reviews
Some changes to the `Patch` state needed for code review.
2024-07-24 16:46:24 +02:00
Fintan Halpenny 81a3bc3d1b
cli: `rad id` allow missing default branch
If a peer had created any references but was also missing the
canonical branch, the `rad id update` command will fail when adding
that peer as a delegate.

Instead, missing delegates and missing default branches are tracked
during verification. If the number of missing delegates means the
`threshold` cannot be met, then the errors are returned.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-07-24 16:43:36 +02:00
Fintan Halpenny dc34eafdf4
remote-helper: allow patch creation from detached HEAD
The patch creation flow would be partially interrupted when creating a
patch via a detached HEAD state. The creation of an upstream branch
would fail since there is no branch to set an upstream for. It would
result in the following error:

    ✓ Patch 6035d2f582afbe01ff23ea87528ae523d76875b6 opened
    To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
     ! [remote rejected] HEAD -> refs/patches (git: reference 'HEAD' is neither a local nor a remote branch.; class=Invalid (3))
    error: failed to push some refs to 'rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi'

To fix this, the reference that's resolved is checked to see if it a
local branch. If not, it will return early.

The behaviour is tested in the `rad-patch-detached-head` example.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-07-23 17:13:30 +02:00
cloudhead 123f7eb6bb
Update `radicle` crate to 0.12.0 2024-07-18 16:22:14 +02:00
cloudhead 297646412a
cli: Use pretty diffs for code review
We use the pretty diff renderer for code review.
2024-07-12 16:39:23 +02:00
cloudhead 823ece875e
cli: Improve pretty diff printing
Refactor, cleanup, improve tests etc.
2024-07-12 16:36:04 +02:00
Alexis Sellier 795ee35f37
cli: Output tree hash after review update 2024-07-11 14:17:17 +02:00
Alexis Sellier 54551b1174
cli: Make sure to configure checkouts properly
We were configure correctly on `rad init`, but not `rad checkout`.
2024-07-09 13:56:10 +02:00
Alexis Sellier 1388601cb6
cli: Fix hunk line ranges
Since the range has a non-exclusive end, we have to add one to it.
2024-07-09 13:46:49 +02:00
Alexis Sellier 605388f850
cli: Implement comment parsing out of diff hunks
Extracts comments out of a string where the diff is quoted with `>` and the
comments are not.
2024-07-09 13:46:44 +02:00
Alexis Sellier d221095980
cli: Add `--unified` flag to `rad diff` help 2024-07-07 16:57:54 +02:00