Commit Graph
95 Commits
Author SHA1 Message Date
cloudhead e57dbc337a scripts: Small fix for POSIX-compliance 2023-09-26 13:11:12 +02:00
cloudhead 1376ab63c0 cli: Allow checking out a specific revision
Allow `rad patch checkout` to specify a revision to checkout that may
not be the patch's latest.
2023-09-21 16:18:24 +02:00
cloudhead c94bd50666 cob: Better distinguish patch revisions
The `Patch` API and semantics are changed a little bit:

* It's now valid again to propose a revision without being the patch
  author.
* To get revisions by the patch author, `Patch::updates` is used.
* `Patch::latest` now only looks at revisions by the patch author.
* Added `Patch::revisions_by`, `Patch::authors` and `Patch::latest_by`.
* The merge behavior on git-push is improved to favor revisions that
  merge more recent commits. We also allow for merging the non-latest
  revision.
2023-09-21 13:51:55 +02:00
cloudhead 5078396028 cli: Move commenting to patch/issue commands
Instead of having `rad comment`, move the command to the respect COBs,
ie. `rad issue comment` and `rad patch comment`.
2023-09-19 14:33:40 +02:00
cloudhead fe5d473af7 cli: Print the identity parent in cob show
The parent that points to the identity document commit was missing
from the output.
2023-09-19 14:22:45 +02:00
cloudhead 8cae60371c cli: Simplified issue opening
We remove the YAML front-matter, since that was annoying to use.
Issues are now edited like patches and commit messages.

Labeling and assigning are done via dedicated commands.
2023-09-19 14:22:45 +02:00
cloudhead 2c4e93b3d2 cli: Show issue comments
When `rad issue show` is run, the issue comments are shown by default.
This can be tweaked using the `--format` option. A value of "header"
only shows the header, while the default which is "full", shows the
header and comments.
2023-09-19 14:22:45 +02:00
cloudhead 457b82f723 cob: Evaluate COB state eagerly
Instead of returning histories from `radicle-cob`, we return an
evaluated object which we build during initial graph traversal.

We do this so that branches can be correctly pruned when operations are
invalid at the application level. This way, new operations are not
building on top of invalid ones contained in the history.

To achieve this, we introduce a new `Evaluate` trait that is implemented
by all COBs, and we make change graph evaluation fallible.

Doing this means that we get `apply` errors returned for free when an
invalid transaction is applied, and no longer need to check for action
validity in multiple places.

We also implement a new `Dag::prune` method to avoid having to copy
graph nodes during traversal.
2023-09-11 23:25:28 +02:00
cloudhead 65fa3cbb1b radicle: Make DraftStore generic over the repo
This will allow using it inside of COBs.
2023-09-10 20:44:38 +02:00
cloudhead 6695074479 cob: Don't require full Entry for update
Instead of taking the full entry type, we only need the id.
2023-09-10 20:44:38 +02:00
cloudheadandArastoo Bozorgi c903a958e7 cob: Implement action authorization
Add `authorization` functions to `Patch` and `Issue` COBs.

Co-authored-by: Arastoo Bozorgi <ab1502@mun.ca>
2023-09-09 18:31:52 +02:00
cloudhead f760b1153f dag: Accept multiple roots in fold, remove depth
This allows the fold to start anywhere in our DAG.
2023-09-07 11:48:21 +02:00
cloudhead 5c256c8bfb cob: Remove support for legacy issues 2023-09-07 11:48:18 +02:00
cloudhead 5fc6d96076 cob: Move action handling into its own function
This change is in preparation for further changes where action handling
is called from multiple places.
2023-09-06 20:40:15 +02:00
cloudhead 287a920d12 cli: Add rad patch set command
Sets the current branch's upstream to point to the given patch.
This allows for pushes to update the patch.

When opening a patch, if the current branch already has an upstream,
it isn't updated automatically. This is why this command exists.
2023-09-06 20:03:58 +02:00
cloudhead 54cc92cc83 cob: Add missing verdict field to review.edit
This is generally useful, and required when constructing a review
without knowing the verdict ahead of time.
2023-09-05 11:17:59 +02:00
cloudhead 152be65053 cob: Wrap patch ID types with new types
To prevent using eg. a `RevisionId` when a `ReviewId` is required,
use compiler types.
2023-09-05 11:17:59 +02:00
cloudhead 16d49c0b82 cli: Don't panic if operation is interrupted
We handle the errors correctly and return.
2023-09-05 11:16:09 +02:00
cloudhead 1ab1da1ba1 cli: Make sure we sync inventory before announcing 2023-09-05 11:16:09 +02:00
cloudhead 112c940d81 cli: Add tests for rad publish 2023-09-05 11:16:09 +02:00
cloudhead 45a2c05a9e cli: Explain how to publish a repo on rad init 2023-09-05 11:16:09 +02:00
cloudhead 1acbe39340 cli: Adjust output of rad sync slightly 2023-09-05 11:16:09 +02:00
cloudhead 9de10ade5a cli: Add --inventory mode to rad sync
This mode allows to announce our inventory. It's not normally needed,
but may be suggested by the `rad publish` command in certain cases.
2023-09-05 11:16:09 +02:00
cloudhead 8199f1a679 cli: Add rad publish command
This command publishes a private repo.
2023-09-05 11:16:05 +02:00
cloudhead 56d6e24ae6 cli: Update rad inspect command
Rename `--id` flag to `--rid`. Update code to match.
2023-09-03 17:21:39 +02:00
cloudhead ba5ed58997 cli: Show repo visibility in rad ls 2023-09-03 17:21:39 +02:00
cloudhead befc76e030 cli: Move init errors up so it fails sooner 2023-09-03 17:21:39 +02:00
cloudhead f2e74fdad2 cli: Choose repo visibility on init
This allows a user to choose private or public visibility on `rad init`.
It also improves the output to tell the user what happened due to this
choice.
2023-09-03 17:21:37 +02:00
cloudhead 8ea9921765 httpd: Better error output from git backend 2023-09-01 15:17:41 +02:00
cloudhead 4fb5f6c172 cli: Simplify fatal error output
It didn't make sense to get eg. `Patch failed` when listing patches
failed. We change all fatal errors to simply "Error:", giving more
control over the individual commands.
2023-09-01 15:17:41 +02:00
cloudhead 27e2f47280 term: Fallback to common editors
When `EDITOR` or `VISUAL` are not set, we fallback to the most common
editors. It turns out many users don't have these variables set.

We also check if an editor has been configured with `git`.
2023-09-01 15:17:41 +02:00
cloudhead 3f592e23d4 httpd: Try lowercase READMEs as well 2023-09-01 15:17:41 +02:00
cloudhead 8d5299fe85 cli: rad patch --help opens man page
This is the same behavior as `git`. We also update the man page to have
the full list of commands and flags.
2023-09-01 15:17:41 +02:00
cloudhead b1213931de cli: Add some hints during interactive rad init 2023-09-01 15:17:41 +02:00
cloudhead 46b0dfb11c cli: Improve rad init error when not in Git repo 2023-09-01 15:17:41 +02:00
cloudhead a84555955d cli: Add PID to node start message
We also use a spinner in case it takes longer.
2023-09-01 15:17:41 +02:00
cloudhead 0123433f81 httpd: Fix clippy warning
Note: because we don't have a working copy here, we can't call
`Merged::cleanup`. We need to figure something out for this.
2023-09-01 15:16:56 +02:00
cloudhead bfc3c7164f tools: Add rad-merge tool
It happened that a small bug in the remote helper caused a patch not to
merge correctly on push. Hence, I implemented a `rad-merge` tool for
these cases where we need to fix broken state.
2023-09-01 14:33:23 +02:00
cloudhead 6c5cba3ca6 cli: Improve patch and issue outputs
* Add author to `issue show`
* Improve author display with alias
* Fix consistency issues when printing authors
2023-09-01 12:26:43 +02:00
cloudhead aec865a986 cli: Fix the color of certain things 2023-09-01 12:26:43 +02:00
cloudhead a46057da1f cli: Update rad ls to look like other commands
We render the output of `ls` as a bordered table, like other tabular
data in the CLI.
2023-09-01 12:26:41 +02:00
cloudhead e59e196da8 cli: Show repo summary on rad clone
After cloning, we show a cool little summary with some repo stats.

We had to make some adjustments to the way visual width is calculated
due to a bug surfaced around emoji width calculation. Unfortunately
there isn't a perfect solution that works across terminals yet, so the
"variation selector 16" code-point is filtered out for now.
2023-09-01 12:22:50 +02:00
cloudhead 0c43b05066 cli: Improve rad node output 2023-09-01 12:22:50 +02:00
cloudhead df0b5da559 cli: Improve node connection error 2023-09-01 12:22:50 +02:00
cloudhead 6fcdb95f0a cli: Improve rad init help output 2023-09-01 12:22:50 +02:00
cloudhead 04d70f27d8 remote-helper: Fix issue with legacy patches
Legacy (or broken) patches prevented merge operations from happening.
2023-09-01 12:21:00 +02:00
cloudhead 9cf20ddef9 Introduce RepositoryInfo type 2023-09-01 12:13:45 +02:00
cloudhead 09a284f09c node: Make fetch timeout configurable
When a fetch is user-requested, a timeout can be supplied that is passed
down to the worker.

When a fetch is service-requested, a default timeout is used.
2023-09-01 12:13:45 +02:00
cloudhead a1df6d3748 cli: Add private repo support to rad sync
We can't use `node::seeds` for private repos.
2023-09-01 12:13:45 +02:00
cloudhead 87c38118d1 cli: Add rad node sessions
Shows node sessions.
2023-09-01 12:13:45 +02:00
cloudhead 9a54c8da7b cli: Update commands for private repos
Several commands are updated to better support private repos.
2023-09-01 12:13:45 +02:00
cloudhead 257b950d6f cli: Add --private option to rad init
Enables private repository initialization.
2023-09-01 12:13:45 +02:00
cloudhead 27f39514d4 node: Implement private repos
Private repos are implemented by extending the identity document with a
`visibility` attribute, that can either be `"public"` (default) or
`"private"`.

In case of `private` visibility, only the delegates are allowed to view
the repo, as well as any DIDs added to the allow list.

To implement repo visibility, we simply block fetches from and
announcements to peers for whom the repo should remain invisible.

Private repos are also not announced in the `inventory` message, since
the full list of peers that *may* have the repo is retrievable from the
repo identity. This could cause errors if eg. a peer who is allowed to
view the repo doesn't actually have it. However this is an ok trade-off
for now to keep the complexity low. For repos to truly be private, it's
important that the RIDs don't leak either.

Finally, we modify `radicle-httpd` for now to only list public repos.
Eventually, we would want to change this depending on whether an allowed
peer is authenticated with the service or not.

---

It's also worth mentioning why this approach was taken, vs. end-to-end
encryption. The reasons are as follows:

1. Nodes that do not have access to a private repo will generally not want to
   replicate encrypted data that they cannot examine or use.
2. The chosen solution is trivial, while encrypting git objects isn't.
3. Performance of the chosen solution is much better, there is no
   overhead.
4. Privacy of the chosen solution is better: RIDs are never leaked, and
   neither is the existence of a private repo, nor who has access to it.

There is one downside: Paying for storage of private repos is no better
in terms of privacy than what GitHub offers. Hosting providers will have
access to your private repos, if this solution is used.
2023-09-01 12:13:45 +02:00
cloudhead 47f09e6ff4 cli: Don't test Git hints in test
These hints are not stable and change with different Git versions. We
ignore them in the test output.
2023-09-01 12:13:05 +02:00
cloudhead d8b5c1ad1c cob: Remove support for legacy patches 2023-08-29 11:52:53 +02:00
cloudhead 205c15caa6 cob: Simplify Entry and Change types
Instead of having two types, we simply have one, called `Entry`, which
we rename from `Change`.

There was no real benefit to having two almost identical types, but lots
of added complexity. This patch simplifies the crate by removing one of
the types.
2023-08-24 12:57:30 +02:00
cloudhead f6bd7a3dc6 node: Fix chrono features
This was failing the build in some circumstances.
2023-08-22 21:24:15 +02:00
cloudhead 8cb8398be9 Introduce cargo-deny
Add `deny.toml` with a few exceptions, and update certain dependencies
to get rid of duplicates.

Running `cargo deny check` will yield some warnings still, but no
errors.
2023-08-22 14:33:00 +02:00
cloudhead 534503d002 cob: Add support for media embeds in COBs
This change allows for files (blobs) to be embedded into COB entries.
This allows for things like image attachments in issue comments for example.

For now, we only enable this in the `issue` COB.

The way it works is that relevant COB actions carry metadata about which
files are attached to them; and we store those files as blobs inside the
COB entry's *tree* object, under an `embeds/` folder.

The `Embed<T>` type is used for the above, and either carries actual
content, or carries a content-id. Retrieving the actual content is as
simple as asking the repository for a blob with that content-id.

As a possible future extension, MIME types could be stored alongside the
files in a "metadata" file. This could help clients display the content
appropriately.
2023-08-22 14:29:23 +02:00
cloudhead f282e09dce cli: Fix test speed regression
These two tests were holding everything up.
2023-08-21 11:57:32 +02:00
cloudhead a922ecf3ce cli: New cob command for debugging
Implement a `rad cob show` command for debugging COBs.
Prints out the full history without decoding the ops.
2023-08-18 10:54:27 +02:00
cloudhead 0358d7bcf0 node: Prefix gossip messages with varint length
This is a breaking protocol change that prefixes all gossip messages
with their length.

This is to allow message extensions, as we'll be able to read the whole
message inclulding the extensions, without having to decode the
extensions.

It also makes it easier to check the message length before we start
decoding, so that we can reject messages that are too big.
2023-08-17 11:48:31 +02:00
cloudhead 87870b521a build: Fix man page building 2023-08-17 11:43:17 +02:00
cloudhead 9bc636ae6e cli: Write test for merge commits with patches 2023-08-16 16:23:32 +02:00
cloudhead 38f326948f cli: Improvements to inspect command
* Add `--delegates` option
* Add `--policy` option
2023-08-16 15:00:23 +02:00
cloudhead 9f5ada5fa9 node: Remove redudnant CLI options
When an option is available as part of the node configuration
(`config.json`), we remove it from the CLI options of `radicle-node`.

Instead, we allow a different config file to be specified via the
`--config` option.
2023-08-16 14:59:45 +02:00
cloudhead c7400e894f docs: Add rad-patch man page 2023-08-16 14:58:54 +02:00
cloudhead a46c6ff36d cli: Add --config option to rad self 2023-08-16 14:58:21 +02:00
cloudhead d9240c9ae9 docs: Update man page about node connections 2023-08-16 14:58:21 +02:00
cloudhead a31f7060e5 cli: Remove extra blank line in rad auth 2023-08-15 11:54:32 +02:00
cloudhead 15b50ce6a5 radicle: Fix config deserialization
This is a fix for the breaking changes introduced with `PeerConfig`.
2023-08-14 10:31:35 +02:00
cloudhead 14c204a11f radicle: Fix flaky test due to randomness 2023-08-13 21:20:27 +02:00
cloudhead d973fd42f2 cli: Auto-connect on sync
This adds functionality so that on `rad sync` and `rad clone`, we
connect to known seeds if necessary, before attempting to fetch.

In passing, some related changes were made:

* The `rad sync` command's arguments were reworked:
  `--replicas <count>` can be used to specify a replica count when
    fetching
* The `rad patch` command no longer has a `--fetch` option
* It's now possible to tell the node not to automatically connect to
  peers in the background
* `AddressBook` is being used underneath `Seeds` to allow for shuffled
  iteration
2023-08-11 11:45:27 +02:00
cloudhead efb8de2728 Rename our custom HashMap to RandomMap
This makes it easier to distinguish with the stdlib.

Also, we add an env var that can control the RNG seed, for testing
purposes.
2023-08-10 16:51:02 +02:00
cloudhead d13f47b2a4 Update toolchain to Rust 1.71 2023-08-09 18:49:13 +02:00
cloudhead 593f576ab4 node: Fix flaky limitter test
Ensures the addresses are different.
2023-08-09 17:07:21 +02:00
cloudhead 8060181b9f httpd: Fix more routes that return the wrong code
These routes should return 404 if the entity was not found.
2023-08-09 16:59:19 +02:00
cloudhead fae518bca2 node: Improve rad node connect feedback
Only return once the connection is established or failed.

It's still not perfect, as several failure scenarios are not handled,
but it's an improvement.
2023-08-09 12:49:15 +02:00
cloudhead fb4a4e0079 node: Implement token-bucket rate limitter
Limit gossip messages and inbound connections.
For now, we don't limit git fetches.
2023-08-09 12:41:21 +02:00
cloudhead 260b1a428c node: Move address field out of State
We move the session address to the top-level struct, since it's needed
in a bunch of places. This change is required for the rate-limiting
code that is coming next.
2023-08-09 12:41:21 +02:00
cloudhead 66799e2211 node: Improve address selection
Improve the logic when choosing addresses to connect to. Previously we
would wait much too long, even for good addresses. This was especially a
problem when the reason for disconnection was simply a node restart.
2023-08-09 12:39:33 +02:00
cloudhead 508cf4f68c node: Connect to peers on startup
We run `maintain_connections` on initialization so that we're
immediately connected to some peers from our address book.
2023-08-09 12:39:33 +02:00
cloudhead 27865a26b2 node: Improve maintain_connections function
Ensure we don't try to connect to two addresses of the same node.
2023-08-09 12:39:33 +02:00
cloudhead dc7d67c1e2 node: Ignore non-routable addresses
We ignore addresses that are not globally routable when receiving them
in node announcement message, unless they are coming from a local peer.
2023-08-09 12:39:33 +02:00
cloudhead e888398519 node: Populate address book with bootstrap nodes
As a starting point, we populate the address book (if empty) with some
bootstrap nodes which are trusted.

To prevent these nodes being connected to during tests (including e2e
tests), we create a new constructor for `Config` that is used in tests.

Note that a `cfg(test)` check is not enough given that e2e tests don't
have that set.
2023-08-09 12:39:33 +02:00
cloudhead 5654f08841 httpd: Fix error status code on project not found
It was 500, should be 404.
2023-08-09 12:01:14 +02:00
cloudhead 1b9906db09 Remove radicle-tui crate
This crate is now in its own repository:

  rid:z39mP9rQAaGmERfUMPULfPUi473tY
2023-08-08 16:31:25 +02:00
cloudhead b456d3a401 Prepare crates for publishing to crates.io 2023-08-07 11:31:11 +02:00
cloudhead 0974a4a164 Cleanup .gitignore 2023-08-04 12:50:08 +02:00
cloudhead 3898fece08 cli: git pull to update patches in working copy
We enable users to pull updates to a patch by calling `git pull`
on the patch branch.
2023-08-04 12:28:22 +02:00
cloudhead 6b143f5f8f term: Some updates to the spinner code
This ensures we don't output progress messages on a non-TTY.
2023-08-04 12:23:58 +02:00
cloudhead c30f137bb1 cli: Add --timeout and --count to node events 2023-08-04 12:23:58 +02:00
cloudhead 2d79eecd66 cli-test: Update framework with new features
* Ability to switch between environments within the same test file
* Ability to expand env vars in `cd` command
2023-08-04 12:23:49 +02:00
cloudhead aea7fb0e42 scripts: Fix delete-remote-branches script
We were deleting patch branches, oops.
2023-08-04 12:19:27 +02:00
cloudhead d0fdd0b6a3 cli: Make rad patch checkout idempotent
Fixes an error when you checkout an already checked out patch.
2023-08-02 11:17:16 +02:00