Commit Graph

2263 Commits

Author SHA1 Message Date
Sebastian Martinez b6cf6fea8d
cli: Fix `rad ls` help message
If the user wants to see all `seeded` repositories, we should tell them
to use the `--seeded` option instead of the `--all` option.

Since `--all` also shows repos that aren't being seeded.
2025-01-14 12:18:40 +01:00
Yorgos Saslis 87cb7bf52d
build: Update zig installation method
This simplifies the Dockerfile a little , as the zig package (0.12.0) is available on alpine 3.20
https://repology.org/project/zig/versions

parent image is also updated to current rust-toolchain

Signed-off-by: Yorgos Saslis <yorgos.work@proton.me>
2024-12-16 11:09:19 +01:00
cloudhead 87f6956e49
build: Fixes to release script 2024-12-16 11:08:27 +01:00
cloudhead d274b28ae0
scripts: Small fix to contributor count 2024-12-05 14:25:28 +01:00
Fintan Halpenny d9c76893a1
cli: bump version to 0.12.1 2024-12-04 12:47:00 +01:00
Fintan Halpenny 19bbdbca24
cli: fix syntax highlighting
There was mishap in updating the parameters of highlight configuration – so many
string types!

This is fixed by adding the correct `name` parameter, reusing the `language`
variable that is being matched on.
2024-12-04 12:47:00 +01:00
cloudhead 7ed72ec918
cli: Fix some clippy lints 2024-12-04 12:46:47 +01:00
Fintan Halpenny 61865b5b5a
cob: fix documentation
`no_run` will compile but not run the code. Use `ignore` instead, and also added
`rust` for syntax highlighting.
2024-12-04 12:40:40 +01:00
cloudhead 8e2fe6449e
scripts: Improve changelog script
* Add number of commits and contributors
* Default to the latest version tag as the "current"
2024-12-04 12:40:10 +01:00
cloudhead 5fe3d5a7ab
cli: Handle broken pipe in `cob show`
When piping the output in for eg. `head -n 1`, the `head` utility
might close down the pipe at some point, yielding a broken pipe error.
We catch that and simply return if that's the case.
2024-12-03 12:36:57 +01:00
Lorenz Leutgeb 7616dcb793
cli/cob: Output JSON Lines 2024-12-03 12:36:02 +01:00
Lorenz Leutgeb 8865b5596e
cli/cob: Allow showing multiple COBs at once 2024-12-03 12:12:50 +01:00
cloudhead 289e59bbfa
term: Bump version to 0.12.0 2024-12-02 13:03:25 +01:00
Lorenz Leutgeb b4f18f43d3
cli: Bump to 0.12.0 2024-11-29 16:31:52 +01:00
Lorenz Leutgeb 1fa1cafee9
cli: Update tree-sitter
Bump `tree-sitter` from 0.20 to 0.24 and replace `tree-sitter-toml` with
the fork `tree-sitter-toml-ng`.
2024-11-29 16:09:53 +01:00
cloudhead fd892d006f
Update `radicle` to 0.14 2024-11-29 15:25:09 +01:00
cloudhead 70f0cc354d
cob: Fix `serde` instances for `ObjectId`
The type now serializes the same as `Oid`.
2024-11-28 15:19:56 +01:00
Lorenz Leutgeb f58af8fef4
cli: Use `term::Table::header` where possible 2024-11-28 14:35:24 +01:00
cloudhead bcba8f5a21
scripts: Add `--from-version` to changelog script
This allows generating changelogs from eg. version 1.1 to 1.2 combining
any pre-releases.
2024-11-27 17:25:02 +01:00
cloudhead 47b200988c
cli: Fix `rad cob migrate` test 2024-11-27 10:19:51 +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 2d13591ec2
radicle: Fix flaky test `counts_by_repo` 2024-11-21 16:05:01 +01:00
Sebastian Martinez a7e96131ce
radicle: add notification count grouped by repo
While the total notification count and the notification count by repo
are needed, for most UIs users will want to see the total notification
count grouped by repo.

This new method will provide this without the need of checking all
possible repos to see if they have notifications.
2024-11-21 12:04:32 +01:00
Fintan Halpenny 259adf7dc2
cob: mutable stable time for testing
The `radicle-cob` crate provides a feature flag, `stable-commit-ids` to allow
for `Oid`s to remain stable for testing by always using the same author and
timestamp when creating commits.

This can be an issue when it interplays with COB related tests that are relying
on the ordering for the DAG walk. If the `Oid` values change and get re-ordered
then the test will fail. The DAG for COBs are now ordered via the `Oid` and
`Timestamp`.

In this change, a global timestamp is introduced that is initialised
per thread. The value is read, via `read_timestamp`, and can be
advanced using `with_advanced_timestamp` – while performing an action
that creates a new commit.
2024-11-18 16:11:44 +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
Fintan Halpenny 159d3fce93
dag: test contains
Test coverage for the `Dag::contains` method were not covered. Add tests for the
method to cover an empty and filled `Dag`.
2024-11-18 11:21:17 +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 088339850b
radicle: introduce identity document version
This change introduces versioning to the identity document format.

The `Version` type is introduced to capture this. Importantly, it is very
restricted in its construction and API. `Version::new` provides a smart
constructor to ensure that it is only ever constructed within the expected
bounds of `0 < v <= IDENTITY_VERSION`, where `IDENTITY_VERSION` is the constant
for the current version.

Note that serializing of the `Doc::version` is skipped to preserve the `Oid`
outputs of all the tests – which means that the first `version` is always
implicit and is not really expected to exist in the serialized forms of the
identity document.
2024-11-14 12:09:28 +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 f9c3523183
e2e: improve flake in missing_delegate_default_branch
The `missing_delegate_default_branch` test was flakey and would fail checking if
Bob had the `rid` in storage.

This can be improved by waiting to ensure that Bob has a `RefsFetched` event
before performing the check.
2024-11-11 11:36: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
Fintan Halpenny eb095c109b
fetch: allow missing default branch
When fetching, the validation logic would prune a delegate if it was missing the
default branch. Originally, this was done to prevent any broken state, but later
it was realised that this can be too restrictive and would not allow nodes to
recover into an improved state.

Remove this check so thtat nodes can still fetch from each other when the
default branch is missing.

An e2e test is added to show that nodes can still fetch from each other and
still receive other references, even when a delegate is missing their default
branch.
2024-11-06 16:47:01 +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
cloudhead 11a6ec5dc6
cob: Add logging to COB evaluation
To use it, run for eg. the following command:

    $ RUST_LOG=debug rad patch cache
2024-11-05 12:14:26 +01:00
cloudhead 0bb0fe8f25
cob: Fix compatibility with certain old patches
We were rejecting patches that were once valid, due to a rule that was
added some time ago. Move that rule one level up, in the write path,
instead of in the read path.
2024-11-04 14:34:30 +01:00
cloudhead 6dcfbfcdee
build: Separate release from upload 2024-11-01 12:28:39 +01:00
cloudhead 09f796234d
radicle: Compute root OID for older remotes
For older clients, `refs/rad/root` won't be set. In that case, compute
it locally based on `refs/rad/id`.
2024-10-31 17:34:03 +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 b4f2614d6c cob: chronological ordering of concurrent values
The underlying `Dag` for a COB will use the `Ord` implementation of
whatever is provided as the key. This means that the lexicographical
ordering of the `Oid` SHA will be used, which in turn means that if
the SHAs change in our tests, then the ordering will be broken for
concurrent updates.

To prevent this from happening, a variant of the `prune` method is
introduced that takes an ordering of the keys and values – this method
being called `prune_by`.

This allows `prune` to be replaced with `prune_by` in the
`ChangeGraph::evaluate` method. The ordering used is first comparing
the `Entry::timestamp` and then the `EntryId` (`Oid`).
2024-10-23 13:02:55 +01: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 f83c116742
radicle: Fix clippy warnings around `unwrap`
The policy should be that we don't use unwraps outside of test code,
unless we have a good reason to.
2024-10-21 16:42:06 +02: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