Commit Graph

578 Commits

Author SHA1 Message Date
Lorenz Leutgeb f58af8fef4
cli: Use `term::Table::header` where possible 2024-11-28 14:35:24 +01:00
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 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 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 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
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
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
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
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
Alexis Sellier 795ee35f37
cli: Output tree hash after review update 2024-07-11 14:17:17 +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
Fintan Halpenny fa19105f2f
cli: add un/resolve for patch review comments
Patch review comments can be resolved and unresolved as part of the Patch COB
API. This functionality was missing from the `rad patch command`.

Add a subcommand `rad patch resolve` which can resolve a review comment, and
unresolve given the `--undo` flag.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-07-03 20:21:46 +02:00
cloudhead 9edb633d98
cli: Add `--from` and other options to `rad seed`
Gives the same options to `rad seed` as `rad sync --fetch`.

Allows seeding and syncing from specific seeds in one command:

  rad seed <rid> --from <nid>

Useful for seeding private repos on public nodes.
2024-06-25 12:01:52 +02:00
cloudhead 6a9f11a1d9
cli: Honor `--quiet` flag in `rad id update` 2024-06-21 13:05:40 +02:00
Fintan Halpenny 80f1e6516c
cli: idempotent `rad id update`
Instead of producing an error when there is no update during `rad id
update`, a message that the document is up to date is printed. The
command is considered is considered successful.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-06-21 13:01:59 +02:00
cloudhead 42ffbf3fe6
cli: Make `rad id update` description optional
If a `--title` is specified, the description is optional, and will be
set to the empty string.
2024-06-20 17:33:48 +02:00
Fintan Halpenny f26be552c2
cli: improve rad id allow list UX
The previous implementation of using the `--allow` option in `rad id
update` would be an absolute list, rather than additive. That is, if
there were existing DIDs not passed in via `--allow` then they would
be remove.

Change this behaviour to check the existing value of the document's
allow list, and add to it if `--allow` is specified.

To enable the user to also remove a DID, the `--disallow` option is
also added.

The correct usage of these options is improved by checking the
validity of the `--visibility` option being used, the current state of
the repository's privacy, and the use of the `--allow` and
`--disallow` options.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-06-20 17:22:38 +02:00
cloudhead 0a7a9c2945
cli: Fix disconnection timestamp
It should show since when we've been disconnected.
2024-06-19 20:37:36 +02:00
cloudhead f0e2018ac5
cli: Correctly update inventory with seed commands
Make sure our inventory is up to date with the policy changes, as well
as when publishing private repositories.
2024-06-12 15:36:34 +02:00
cloudhead fc55d67929
cli: Add `rad node inventory` command
Prints the local node's inventory.
2024-06-12 15:36:34 +02:00
cloudhead 81f94d0cff
cli: Move common functionality out of the CLI 2024-06-12 15:36:34 +02:00
cloudhead b24f8a30d6
node: Update inventory when unseeding
Previously, our advertized inventory was not always correct: when we
stopped seeding a repository, it was still advertised as part of our
inventory until node restart, because the `Storage` type doesn't have
access to seeding policies.

In this change, we remove the concept of inventory from `Storage` and
make the authoritative place for it the routing table in our database.

To make this work, we have to add our node to the database on profile
creation, to not violate the foreign key constraint on the routing
table. Hence, the tests are changed to include our alias which is now
always available.
2024-06-12 15:36:34 +02:00
Alexis Sellier 3ae7e305bd
node: Simplify configuration
This is a change to the `config.json` file which removes certain options
that are best not touched and changes some options to make them easier
to work with.

1. We change the default journaling mode to "wal" and remove the config
   option.
2. We remove the option to set the peer connection "target", as it's not
   a good idea to set this to a different value, as it affects the
   network.
3. We combine seeding policy & scope, since there's no need to set the
   scope when the policy is "block". In that case, we always want to
   block "all" remotes. The new policy configuration has the following
   schema:

   { seedingPolicy: { default: "block" | "allow", scope?: "all" | "followed" } }

   The "scope" key is not used when "default" is set to "block".

4. We add an `extra` field to the node config for options that are not
   recognized. We use this to warn the user.
2024-06-04 14:08:15 +02:00
cloudhead cc7d0cf363
cli: Fix `rad id show` delegate output
We were not showing the correct list of delegates, we were always
showing the "current" list.
2024-06-04 11:10:29 +02:00
Lars Wirzenius db98daecca
cli: make `rad debug` work without a profile
Reported-by: Lorenz Leutgeb
Signed-off-by: Lars Wirzenius <liw@liw.fi>
2024-05-24 17:04:22 +02:00
cloudhead 61733ebb95
cli: Allow `--inventory` and `--announce` together
Allow these flags to be used together, since we are announcing the
inventory.
2024-05-24 11:10:48 +02:00
Lorenz Leutgeb 6d11ea17c8
cli: Implement `rad cob show` with new meaning 2024-05-22 11:56:01 +02:00
Lorenz Leutgeb 6147a8a2fb
cli: Add `rad cob log` format options
Add `--format json` and `--format pretty`.
2024-05-22 11:54:25 +02:00
Lorenz Leutgeb 72dad241e2
cli: `rad cob {show → log}` 2024-05-22 11:47:09 +02:00
cloudhead 30c9b0db0b
cli: Add `rad node debug` command 2024-05-21 16:00:30 +02:00