Commit Graph

701 Commits

Author SHA1 Message Date
cloudhead 7abfd4870c
term: Overhaul rendering
The `Element::render` function now takes a constraint object. This
allows the parent element to influence how the child is rendered. This
is useful eg. to have elements take up more space than they need to fill
some space.

We also make various changes needed for pretty diffs, such as merging
styles, a new `Filled` type, and some color theming.
2023-09-27 12:37:41 +02:00
cloudhead b482ae85f0
remote-helper: Run sync on `git-fetch`
Changes the behavior of `git fetch` by running a radicle network-level
fetch (ie. `rad sync --fetch`) before fetching refs from storage. This
avoids having to run `rad sync` before `git fetch`; and tries to make
sure that refs are always fresh.
2023-09-27 12:29:46 +02:00
Alexis Sellier 7e32f91ea2
Don't allow the default branch to be deleted
As a delegate, you shouldn't be able to delete your default branch.
This would most likely happen by mistake, and it prevents the canonical
head from being calculated correctly.
2023-09-27 12:25:15 +02:00
Alexis Sellier c0271c303f
Prevent divergences in canonical head
On push, we check whether the resulting state would cause a
divergence/fork in the canonical head, and if so, prevent the push from
happening.

This is to avoid situations where delegates have to then rollback their
heads.

Note that this doesn't prevent forks from happening altogether, as they
could happen asychronously, but it mitigates the problem.
2023-09-27 12:25:14 +02:00
Alexis Sellier 5c326cf242
cli: Sign refs and set head in `rad delegate add` 2023-09-27 12:25:14 +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
Slack Coder 8e58ba6433
cli: Implement DDiff
Define types to support Diff of Diffs leaning on the Radicle Surf types.

Use Radicle Surf's Hunk type, but custom Diff, FileDiff, and
Modification types, and avoid Serde serialization as it does not yet
seem necessary.
2023-09-19 15:22:42 +02:00
Slack Coder cb78f144be
cli: Add diff parsing
Parse Git's unified diff format into Radicle Surf's types.  Support to
and from the format helps testing and debugging.

Split the UnifiedDiff trait into Decode and Encode traits so we
can offer Decode in cases where no data could be expected..
For example Option<Hunk<_>> and Hunk<_> allowing partial and repeated
decoding on a byte stream.

Avoid decoding `Diff`, `DiffContent::Binary`, `FileDiff`, and `FileHeader`
types.  `Diff` keeps fields and methods private which are necessary for
decoding.
2023-09-19 15:18:50 +02:00
Slack Coder b337e1b1cb
cli: Define UnifiedDiff on concrete type
Simplify the trait by defining it on the concrete type, which appears to
be the standard rust approach.  Remove some oddities in the process (refs
of refs).
2023-09-19 14:46:18 +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
Alexis Sellier af724eeb0d
cli: Add `node config` command
Shows the current (loaded) node configuration.
2023-09-18 11:14:19 +02:00
Sebastian Martinez 6bb0dd1a28
Update `radicle-surf` to `v0.15.0`
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-09-18 10:57:37 +02:00
cloudhead 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 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
Alexis Sellier 579ddfe725
cli: Give passphrase error on prompt
Example:

    ✗ Invalid passphrase, please try again
    ? Passphrase: ***
2023-09-06 20:03:58 +02:00
Alexis Sellier 5040f33025
cli: Be less confusing when asking for passphrase
The previous error didn't really make sense.
2023-09-06 20:03:58 +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 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 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 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 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 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 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 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 a46c6ff36d
cli: Add `--config` option to `rad self` 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
Sebastian Martinez 6abbd39926
httpd: Allow removing of reactions from issues
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-08-14 16:41:04 +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 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 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 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
Alexis Sellier 3bd5589b1a
cob: Stabilize formats
> I'm going to be making a set of breaking changes to COBs in order to
stabilize the data formats. This is hopefully a one-time change that
bundles various breaking changes.

All COBs have been reworked: issue, patch, id.

The changes included are:

* Revise the assign and tag actions to take a single list of
  assignees/tags to set, instead of an "add" and a "remove" list. This
  makes API usage simpler when editing issues, and simplifies the apply
  function
* Rename "tags" to "labels", and the tag action to label. This is
  because tag is confusing in the context of git, as it could mean a git
  tag. Using label removes that confusion.
* Use DIDs instead of PublicKeys for assignees -- this is more
  future-proof
* Modify the manifest file format in the COB tree. Mainly, remove the
  `history_type` key which is redundant, and use camelCase for keys
* Flatten the `Thread` actions into the parent action type
* Ensure that operations on redacted objects do not fail, since
  redactions could have happened concurrently
* Use a consistent naming scheme for actions, using `.` as separator
* Consolidate comment types and remove `CodeComment`, by adding an
  optional `location` field to `Comment`
* Add many placeholder actions that are not yet implemented

To preserve backwards compatibility, a `legacy` module is created with
the old `apply` function. When loading the manifest, we check whether it
is a legacy COB or a "stable" COB, and in the legacy case, use the
legacy code to materialize the state and then convert the object into
the stable type. Eventually, we'll delete the legacy code.
2023-08-07 11:05:14 +02:00
Alexis Sellier 885f4999da
remote-helper: Fix refs advertisement for patches
Some of the old patches had missing objects and that causes problems
during the ref advertisement, as the object is not found.

In this patch, we check that the object exists and also that the patch
is still open. Otherwise a remote tracking branch is created for every
single patch ref.
2023-08-06 17:29:21 +02:00
Slack Coder 0141313b35
cli: Refactor git diff encoding
Move code for writing radicle_surf diff's in git's unified diff format
into its own module.  Lean on the type system by defining a
`UnifiedDiff` trait to provide a method `encode` to encode to the
format and another default method to convert to a git 'unified' diff
string.

Additionally a `Header` struct is added to support processing Unified
Diff files.  The Header's line numbers must be tracked and modified to
produce legal diff files.

This is in preparation for DDiff support.  Upcoming improvements will
include parse unified diff's into these types to support test data.
2023-08-04 12:45:53 +02:00
Slack Coder 6ed3ab914d
cli: Vanity update for review
Reduce duplicate hard to read code by using a closure.
2023-08-04 12:44:28 +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 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
Alexis Sellier 2ea9a911af
remote-helper: Handle patch update after merge
If you accidently merge updated patch code before updating the patch in
storage, you end up in this weird state where you can't update the patch
any longer. This fixes it.
2023-08-03 18:01:04 +02:00
Slack Coder 67a8ee9e86
cli: Remove rad-inspect `tree' dependency
Hard code output similar to the 'tree' command in rust to avoid having
to shell out.
2023-08-03 13:40:48 +02:00
Vincenzo Palazzo f91ef2963e
cli: Fix partial matching for the --seed flag
This commit addresses the inconsistent parsing of the command by fixing the
partial matching behavior for the `--seed` flag. Previously, specifying
the seed value resulted in an invalid option error, as shown in the example below:

```
➜ ~ rad sync --seed z6MksmpU5b1dS7oaqF2bHXhQi1DWy2hB7Mh9CuN7y1DN6QSz
✗ Error: rad sync: invalid option '--seed'
```

With this fix, there are no restrictions on when the seed can be specified.

In a future change, we plan to implement a custom error message when a
match case does not meet specific requirements, such as `rad --fetch --announce`,
which will return a more informative error message. However, this
enhancement is left for a derived solution.

```
➜  ~ rad sync --fetch --announce
✗ Error: rad sync: invalid option '--announce'
```

Fixes: d6cebf613f
Suggested-by: Slack Coder
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-08-03 13:34:23 +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
Alexis Sellier 8a3133e137
node: Include addresses in `Command::Seeds` result
This will allow the CLI to connect to seeds on the go.

We also do some refactoring of some of the code involved in fulfilling
the `Seeds` command.
2023-08-01 15:48:44 +02:00
Alexis Sellier 693f0a2c44
node: Some small UX fixes
Fixes an error which said "invalid argument" the first time the node was
started.
2023-08-01 14:55:20 +02:00
Sebastian Martinez 3366535c9d
rad: Disable tests that use `sed` on macos
Due to differences between how BSD sed and GNU sed work, we disable for
now tests that use sed on macos

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-07-26 13:23:15 +02:00
Alexis Sellier 41bff1b3bb
node: Make user connections persistent
While the node is running, connections made via the `Connect` command
should be retried.
2023-07-26 12:52:11 +02:00
Alexis Sellier f639192dc6
cob: Remove CRDTs from COB state
It turns out that the CRDT formed by the union of Git DAGs
is enough to guarantee everything we need for COBs.

This changes the following things:
* COB operations no longer need to be commutative
* COB histories are traversed in the same deterministic order on all
  replicas
* It's now possible to implement RSMs on top of COBs, eg. scripting
* Lamport clocks have been removed
* `radicle-crdt` is no longer a dependency of `radicle`
* COBs are no longer instances of `Semilattice`
* The `Ops` type was removed in favor of having `Op` contain multiple
  actions
2023-07-25 15:29:27 +02:00
xphoniex 4869fe26e2
Add `-h` flag to binaries
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-07-25 11:58:39 +02:00
Michail Zampetakis 0e54c4a293
cli: Fix rad-fetch readme link 2023-07-25 11:52:24 +02:00
Slack Coder 1edab8c9a6
cli: Select review target by Revision ID
Support testing the review system against real world data by accepting
a Revision ID.
2023-07-25 11:45:12 +02:00
Slack Coder 2a0643cf1c
cli: Vanity review.rs update
Absorb a nested `if .. else` block into the match statement.
2023-07-25 11:45:12 +02:00
Slack Coder fe00ed7ca7
cli: `rad issue list` open issues by default
Help the user by reducing the amount of output.  A user is generally
only interested in open issues.  The '--all' flag is provided to list
all issues.
2023-07-25 11:39:39 +02:00
Alexis Sellier 3119294367
Add `--version` flag to binaries
Help users confirm all their radicle binary versions by providing the
'--version' flag.

Move the print_version function to the radicle crate for use by the node
and remote-rad binaries, and remove tests to confirm the output format
as it is deemed redundant.

Co-Developed-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-07-25 11:36:50 +02:00
Alexis Sellier 18dacbb48c
cli: Start node in background by default
It makes much more sense to start the node in the background, now that
we have commands to interact with it.
2023-07-20 10:40:30 +02:00
Alexis Sellier edd70b701e
cli: Give hint on how to start node, when stopped
Also enable some tests that were disabled.
2023-07-20 10:40:24 +02:00
Alexis Sellier b827c6bc54
cli: Fix `rad self` output
By using strings that include ansi escape codes, we had broken
truncation behavior.
2023-07-20 10:40:19 +02:00
Alexis Sellier f92308cf25
cli: Make key encryption optional
By leaving the passphrase prompt blank, users can create unencrypted
keys.
2023-07-20 10:40:15 +02:00
Alexis Sellier e593191ae2
cli: Automatically remove control socket
Instead of requiring that `--force` be used manually, we check to make
sure the node is not running, and if so, pass `--force` to the node
process.
2023-07-20 10:39:36 +02:00
Alexis Sellier ff7e9ded17
radicle: Introduce `cob::DraftStore`
This storage backend for COBs stores changes in a `draft/cobs/*` namespace,
which allows for some of the features needed for code review. For
example, users can draft comments and later decide to publish
them.
2023-07-14 16:57:55 +02:00
Alexis Sellier c9162121b0
cob: Parametrize `cob::Store` with repository type
The additional flexibility in choosing a backend for the COB store will
allow things like "draft" COBs that are stored in a different location,
without changing much of the logic.
2023-07-14 16:57:55 +02:00
Alexis Sellier 45ccbde226
Update `radicle-surf` and `git-ref-format` 2023-07-14 16:57:55 +02:00
Fintan Halpenny dfa7ba1df5
radicle: type safe tracking config
The tracking database can be opened in read-only or read-write
mode. Knowing which is being used is significant in concurrent
scenarios, e.g. it's safer to have a read-only handle on multiple
threads.

Provide static type information by signifying what kind of database
handle is being worked with, read or read-write.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-07-14 16:52:42 +02:00
Alexis Sellier b27313bc5c
Don't fail if we can't open the database
We make sure that even if there is no database file, we're still able
to return `None` for the alias lookup.
2023-07-12 11:37:20 +02:00
Alexis Sellier eb701be033
node: Make node aliases required
This is a fairly substantial change, which adds a new configuration file
to the user's `$RAD_HOME` that includes node configuration, including
the alias, and also makes node aliases required.

When running `rad auth`, the user is now prompted for an alias, which
defaults to `$USER`.

When running `rad self`, the alias is now shown.

If the user runs radicle without a config file, the defaults are loaded,
and `$USER` is used as the alias.
2023-07-11 18:08:59 +02:00
Sebastian Martinez 8ed55a1925
cli: Add `--to` flag to `rad issue react`
This allows the CLI to create a reaction to a specific comment without showing the
comment selector.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-07-10 16:41:42 +02:00
xphoniex 329ccbb304
cli: Add alias and check `rad patch` & `rad issue`
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-07-10 16:36:15 +02:00
xphoniex 1459e4a57f
cli: Use `.aliases()` store for issues
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-07-10 16:36:15 +02:00
xphoniex 37847d4c63
cli: Use `.aliases()` store for patches
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-07-10 16:36:15 +02:00
Alexis Sellier 1a1e63d998
node: Implement `sessions` command
Returns session information through the control socket.

We also update `rad node status` to display sessions.
2023-07-04 00:26:31 +02:00
Alexis Sellier f73389fc62
cli: Make `rad node connect` work like `--connect`
It was using a different syntax.
2023-07-04 00:26:31 +02:00
Alexis Sellier 45e87a63b9
cob: Changes to patch code review CRDT
This patch incorporates several important changes to code review:

* Code review verdict is no longer editable
  * Made reviews redactable instead
* Renamed review top-level comment to "summary"
* Renamed inline comments to "comments"
* Made inline comments addressable by `EntryId`
  * This is to allow for editing
* Removed inline comments from review creation
  * Added a `CodeComment` action instead
* Removed `Semilattice` instance from `Review`
  * Added a `EditReview` action instead to have more control
* Made it valid for revisions to be redacted concurrently with a review/merge

Most of these changes are needed to support proper inline code comments.
2023-07-03 12:31:05 +02:00
Alexis Sellier 0f3212a1b2
cli: `rad self` improvements
* Add `--home` flag
* Organize the information better

Now looks like this:

    DID             did🔑z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
    └╴Node ID (NID) z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
    SSH             running (823)
    ├╴Key (hash)    SHA256:UIedaL6Cxm6OUErh9GQUzzglSk7VpQlVTI1TAFB/HWA
    └╴Key (full)    ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHahWSBEpuT1ESZbynOmBNkLBSnR32Ar4woZqSV2YNH1
    Home            [..]
    ├╴Storage       [..]/storage
    ├╴Keys          [..]/keys
    └╴Node          [..]/node
2023-06-30 14:41:00 +02:00
Alexis Sellier 613e3e5269
cli: Show logs after `rad node start`
When the node is started, we show the first few log lines.
2023-06-29 18:45:16 +02:00
Alexis Sellier 2e6c9827a9
cli: Show logs in `rad node status` 2023-06-29 18:01:49 +02:00
Alexis Sellier e32e28f8b4
cli: Implement `rad node stop` 2023-06-29 17:58:07 +02:00
Alexis Sellier 0d0d354d55
cli: Ask for passphrase upfront in `node start` 2023-06-29 15:02:08 +02:00
Alexis Sellier ba9c5997b7
cli: Add `rad node logs` sub-command
Prints the last `n` lines and follows the log.
2023-06-29 14:58:11 +02:00
Alexis Sellier 63ff4717dc
cli: Implement hunk-based code review
Review code with an interface similar to `git add -p`.
2023-06-22 11:15:42 +02:00
Alexis Sellier e325fa8621
cli: Turn `patch update` into a plumbing command
Remove most of the user-friendly functionality and simplify this command
so that it is only used for scripting.

`git push rad` is now the proper way of updating patches.
2023-06-21 17:02:00 +02:00
Alexis Sellier b25c2e452b
cli: Setup tracking branch on `rad patch checkout`
Just like when opening a new patch, we setup a tracking branch on patch
checkout, so that patches can be updated via a push.
2023-06-21 17:01:56 +02:00
Alexis Sellier 1e948485be
cli: Make some UX improvements to `rad auth`
Better errors, messaging etc.
2023-06-20 16:05:35 +02:00
Alexis Sellier 074b0e55c1
cli: Add user alias to `rad auth`
We were outputting `(me)` previously.
2023-06-20 15:45:14 +02:00
Alexis Sellier cb576cf8c3
cli: Allow setting a different patch base on push
Using `-o patch.base=<oid>`, users can specify a different patch base,
when creating or updating a patch.
2023-06-15 10:25:32 +02:00
Alexis Sellier a6782ac2d6
cli: Add `-v` flag to `rad patch show`
With this flag, additional data such as the patch base is shown.
2023-06-13 13:17:07 +02:00
Alexis Sellier 48f44f4af5
cli: Fix ahead/behind and diff behavior
In certain cases, eg. after a rebase, or when patches are stacked, the
"ahead/behind" and/or the diff stats can be wrong.

This fixes it.
2023-06-13 13:16:00 +02:00
Alexis Sellier ec064891cd
cli: Setup tracking branch on `rad remote add` 2023-06-13 11:09:42 +02:00
Alexis Sellier e9ef0f4aa4
cli: Consolidate working copy remote setup
We consolidate the setup done by `rad checkout`, `rad clone` and `rad
remote add`, so that they all check for node aliases, and are all
capable of setting up tracking branches etc.
2023-06-13 11:09:42 +02:00
Alexis Sellier 50a97d9add
cli: Add `--scope` flag to `rad init`
Defaults to `all`.
2023-06-13 11:09:42 +02:00
Alexis Sellier 06566dac6f
cli: Add `--scope` flag for `rad clone`
This allows for a scope to be specified when cloning.

We also change the default scope when cloning to 'all' to more closely
match user expectations.
2023-06-13 11:09:42 +02:00
Alexis Sellier 64708954ca
cli: Remove redundant newline in patch message
There was an extra newline in the patch creation message due to not
accounting for commit messages with newlines at the end.

This is fixed and the tests are updated to be more realistic.
2023-06-08 16:47:30 +02:00
Alexis Sellier 0319bbb903
remote-helper: Don't allow opening an empty patch
If the commit range is empty, return an error.
2023-06-08 16:42:14 +02:00
Alexis Sellier 3d803b2498
cli: Remove `rad patch open`
Remove this command in favor of the `git push` flow.

We also remove the `rad/patches` remote configuration which wasn't
working properly with `git fetch --all`.
2023-06-07 15:57:11 +02:00
Alexis Sellier 547fdcc03b
remote-helper: Create patch drafts via `git push`
This is now possible via the `-o patch.draft` push option.
2023-06-07 15:02:05 +02:00
Slack Coder 6bbdc574f0
cli: Use clearer format for string literals
Update the string literals in `rad patch` to use an easier to read
format.
2023-06-07 12:11:36 +02:00
Slack Coder 92648f934e
cli: Patch message from all commits
Help the user when creating a patch by listing the messages of all
commits associated with the patch in almost the same format as git uses
for squashing.
2023-06-07 12:11:33 +02:00
Vincenzo Palazzo 520fb61230
cli: Fix another issue with unspecified editor
This commit includes a fix for another occurrence of
the missing `EDITOR` variable. This time, it was
inside the `rad edit` command.

The fix is trivial, as it simply returns the error to the caller.

Co-Developed-by: Slack Coder <slackcoder@server.ky>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-06-07 11:58:15 +02:00
Michail Zampetakis 75139a6f02
cli: Fix help of the fork command 2023-06-07 11:52:46 +02:00
Slack Coder d335e1f3a5
cli: Use html comments for `rad comment`
Be consistent by using the same message style as 'rad patch' and 'rad
issue'
2023-06-07 11:50:54 +02:00
Slack Coder 16822ff84e
cli: Prevent weird `rad issue open` behavior
Verify special YAML strings '~' and 'null' are filtered out when
processing the input from the editor.

Serde replaces empty strings with their values causing an empty title to
become '~'.  Best to avoid them entirely and be transparent about it.

The solution is not meant to be long term.  This editor format for
getting issue data will be replaced in the near term.
2023-06-07 11:50:27 +02:00
Slack Coder 5d20316c57
cli: Fix accidental issue creation
When a user is creating an issue via the editor, it is very easy to
accidentally create an issue.

To fix this, make the default description also 'empty' and bail out if
either it or the title are empty.

Retain the default 'description' message by providing it as a comment.
2023-06-07 11:48:49 +02:00
Alexis Sellier e86e061a12
remote-helper: Patch message option when pushing
Allows for setting a patch message during a push. Eg.:

    $ git push -o patch.message="My Title" -o patch.message="My description" \
      rad HEAD:refs/patches

Works the same way as the `-m` flag of `git commit`.
2023-06-07 11:37:39 +02:00
Sebastian Martinez 6578fedfbb
cli: Add issue id to `show_issue` function
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-06-06 11:11:20 +02:00
Slack Coder 65763a2ad2
cli: Enable redacting patch revisions
Use `rad patch redact <revision-id>` to redact (delete) a patch
revision.
2023-06-02 17:30:13 +02:00
Alexis Sellier 4652f309b4
Update to Rust 1.70 2023-06-02 14:40:44 +02:00
Slack Coder 1c9670b90f
cli: Fix `rad issue edit`
Make the `rad issue edit` subcommand accessible to users.
2023-06-01 14:00:33 +02:00
Alexis Sellier 97f122c451
cli-test: Build radicle binaries automatically
To avoid having to call `cargo build` before running the tests, we build
the necessary binaries automatically using the `escargot` crate.
2023-05-31 17:21:12 +02:00
Sebastian Martinez c2dd778183
cli: Add `--json` flag to `rad web`
This allows third party integrations to read the obtained sessionId and
the signed payload without having to implement it on their own.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-05-30 10:39:37 +02:00
Slack Coder 22c7945e7b
cli: Strip html comments 2023-05-30 10:34:36 +02:00
Slack Coder 02f5596c05
cli: Add state filters for `rad issue list`
Allow filtering the issues by their state.
2023-05-29 19:50:33 +02:00
Slack Coder 3af53626f0
cli: Reorder method arguments
Reorder the method arguments in the commands to make them consistent.
2023-05-29 12:42:55 +02:00
Slack Coder f2d4b9acc2
cli: Support `rad issue edit`
Support editing an issue via the command line.
2023-05-29 12:22:51 +02:00
Slack Coder 478b61f875
cli: Refactor `rad issue open`
Lift the issue editing logic into its own function.
2023-05-29 12:22:50 +02:00
Alexis Sellier 01ab91db86
cli: Fix sort order for patch listing 2023-05-29 12:02:59 +02:00
Alexis Sellier eeaf380067
cob: Add validation step when loading COBs
This adds a simple `validate` function to COBs that is run on load. It
allows COBs to check whether they are valid, once all operations are
loaded, and return an error if not.
2023-05-29 11:27:04 +02:00
Alexis Sellier e6baeab0c9
cob: Guarantee there is always a latest revision
We change `Patch::latest` to always return something, because a patch is
malformed if it doesn't have at least one revision, and thus would not
load in the first place.

This also implies that there is a latest revision in the face of
concurrent updates.

Note that currently, traversal order for concurrent updates is still random.
This will be fixed in another patch.
2023-05-26 10:31:00 +02:00
Alexis Sellier ac60069a33
cob: Remove `description` from `Patch`
Since patches always have a "root" revision, use that revision's description
as the patch description.
2023-05-26 10:31:00 +02:00
Alexis Sellier ac06e319cd
remote-helper: Delete patch branches after merge
This cleans up the branches that were created during patch open, when a
patch is merged.
2023-05-25 10:07:02 +02:00
Alexis Sellier 4176d62e38
remote-helper: Add `no-sync` push option
This is mainly useful for scripting, when for eg. you want to push
multiple things and sync only once, at the end.
2023-05-25 10:07:02 +02:00
Alexis Sellier 366e61a053
cli: Improve error output of commands
Previously, we would sometimes get very repetitive error messages. This
change prevents that from happening.
2023-05-24 11:33:55 +02:00
Alexis Sellier 45a4578724
cli: Move `announce` function to `node` library
This will be used in more than one place.
2023-05-23 16:11:42 +02:00
Alexis Sellier 8e89976937
cli: Verify merge, remove `rad merge` command
When applying a `Merge` action, we verify that the commit is in the
history of the default branch of that user.

Since this is not the case when issuing a `rad merge`, and since that
command is no longer needed with the push-based merge, we remove the
`rad merge` command completely.
2023-05-23 16:11:42 +02:00
xphoniex 95e3b9673d
cli: Show alias on `rad issue` and `rad patch`
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-05-22 15:13:28 +02:00
Sebastian Martinez 76ba25268d
cli: Add routing entries per rid and or nid
To allow third party tools read the routing table entries filtered by
rid or nid and if needed in json format.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-05-22 11:58:43 +02:00
Alexis Sellier 2d55ffba81
cob: Redesign merge state
Move `merges` from `Revision` to `Patch`, and key them by actor.

This ensures that only one merge is possible per actor. We also make
sure that only one revision can be merged at a time, and signal a
conflict if more than one revision is considered merged.

Finally, we make sure that merges have the same target-branch commit
to be considered equal.
2023-05-19 18:40:46 +02:00
Sebastian Martinez 8d8751655f
cli: Add `rad node events` command
Allows third party implementations to listen to the event stream of a
node.

In case of a serialization error we exit the event subscription and end
the process.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-05-17 16:55:06 +02:00
Alexis Sellier 90237e8e9d
cli: Fix some tests that are no longer valid 2023-05-17 16:54:30 +02:00
Alexis Sellier 94cd7658b1
cli: Merge patches on `git push`
Allows patches to have their state updated to `Merged` with a `git push`
to the default branch.

Currently, due to the limitations of the COB store, this requires a
linear search through all patches. This will eventually become a problem
when projects have thousands of patches, so we should look into
long-term solutions.
2023-05-16 21:11:57 +02:00
Alexis Sellier a1674600e9
cli: Fix merge commit oid
We were storing the commit *before* the merge in the COB, instead of
storing the commit *after* the merge.
2023-05-16 21:11:57 +02:00
Alexis Sellier 8202495e24
cli: Rework `rad sync` command
By default, `rad sync` will both fetch and announce now.

To only fetch or only announce, the `--fetch` or `--announce` flags
can be used.
2023-05-15 15:34:45 +02:00
Alexis Sellier f72b448114
cli: Fix `rad patch show` with merged patches
We were not correctly calculating the base commit. Simply
using the latest revision base does the job for now.
2023-05-15 12:22:09 +02:00
Alexis Sellier a9c0152a99
cli: Use library for updating patch
Also improves the message from a bare revision id.
2023-05-15 12:22:09 +02:00
Alexis Sellier 51dced4808
cli: Use library for opening patch
Instead of calling `rad patch open`, use `patch::create` directly.

Also outputs the patch id for the user.
2023-05-15 12:22:09 +02:00
Slack Coder ad48514ddd
cli: Fix workflow test
'git pull' in workflow/6-pulling-contributor causes a message to be
emitted for some git versions.  It asks to configure 'git pull's default
action.

Use '--ff' as a workaround as a git config file is unsupported, and no
environment variable exists for this configuration.
2023-05-14 13:50:20 +02:00
Alexis Sellier e7cc32a278
cli: Update some of the output formatting 2023-05-12 13:09:42 +02:00
Alexis Sellier dd7d86abb0
cli: Update examples to use new `fail` decorator 2023-05-12 12:54:21 +02:00
Alexis Sellier 103ee4e23d
cli: Show commit listing in `rad patch show` 2023-05-12 12:43:44 +02:00
Alexis Sellier fd1237b2db
cli: Use `git push` to open or update patches
This adds the ability to the git-remote-helper to open and update
patches via a `git push` to the magic ref `refs/patches` and
`refs/heads/patches/<patch-id>`.

The main change is that we had to move away from offering the `connect`
capability in the remote helper, to offering `push` and `fetch`
individually.

To get a feel for how this works, see the `rad-patch-via-push.md`
example.
2023-05-12 12:22:08 +02:00
Alexis Sellier f8ee109aaa
cli: Set a working `EDITOR` env var in tests
Previously, commands would just fail. Now it runs the `true` command
that always returns success.
2023-05-12 11:09:21 +02:00
Alexis Sellier d249937a61
Update dependencies
* radicle-surf
* radicle-git-ext
* amplify
2023-05-10 15:56:21 +02:00
Fintan Halpenny 8508eab8fa
radicle: update radicle-git-ext
This change updates to the latest radicle-git-ext, which required a
few changes within the radicle family of crates.

One set of changes is that the radicle-git-ext crate subsumes
git-commit, git-trailers, and git-ref-format -- so all those imports
go through radicle-git-ext.

The commit code requires that parent `Oid`s point to commits, which
made some tests fail. One of the reasons for these failures is that
the patch tests used fabricated `Oid`s and so the verification would
fail. This is fixed by allowing the test context code to create
`PatchRequest`s that create valid commits.
The other reason for failure was that the identity `Action` passed an
`Oid` that pointed to a blob. This is fixed by removing that code and
making a note of it in documentation.

The final major change was moving the Refspec type into git-ref-format
and removing the AsRefspecs trait. The trait was not required and
could its usage could be replaced by simpler code.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-05-08 10:36:15 +01:00
Fintan Halpenny 2ff6bf2fc4
cli: remove the 'rad' remote during `rad rm`
If the 'rad' remote is still in the git config, then some of the CLI
tooling will think the project exists -- even after running `rad rm`.

For example, in the current state, if `rad rm` is followed by `rad
init` then the operation will fail.

During `rad rm`, attempt to delete the 'rad' remote.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-05-08 10:49:18 +02:00
Fintan Halpenny c49412a73f
cli: allow rad rm to untrack without running node
Previously, `rad rm` would require the node to be running to untrack
the repository.

This is no longer necessary since the tracking db is exposed via the
`radicle` crate. Instead, use the db directly to untrack the RID
during `rad rm`, as long as the node is not already running.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-05-08 10:49:18 +02:00
Slack Coder 6fe5dfa3c9
cli: Refactor `rad issue open`
Make code clearer by lifting it into its own method.
2023-05-08 10:40:45 +02:00
Slack Coder f4dff17085
cli: Refactor `rad issue list`
Move code into its own method.
2023-05-08 10:40:45 +02:00
Slack Coder e0241050f8
cli: List issues consistent
Help the user by ordering issue listing by their creation time to make
it consistent.
2023-05-08 10:40:45 +02:00
Slack Coder 3e2cf83f9b
cli: List patches by last update
To help users notice changes to patches, make `rad patch` order patches
by revision timestamp instead of patch timestamp.
2023-05-08 10:32:48 +02:00
Slack Coder 091154faed
cli: Make patch listing deterministic
Help the users by making the patch listing consistent.  Order the
patches by their creation time and id.
2023-05-08 10:32:48 +02:00
Slack Coder b5a00dfc4c
cli: Clarify user facing patch message
Now logic for parsing and supporting user facing Patch messages is
shared for creation and editing, refactor and move supporting code to
terminal::patch.

This fixes a bug where the title may be incorrectly parsed, resulting in
it containing multiple lines.
2023-05-05 17:22:20 +02:00
Slack Coder 6bedb1256c
cli: Make patch editable
Add `rad patch edit` to make the patch description editable.
2023-05-05 17:21:53 +02:00
Alexis Sellier 0886ab0a3c
node: Get the failing fetch tests passing
We fix the failing fetch tests by:

1. Not verifying our own refs, unless we're cloning, since we're
   otherwise not fetching our own refs.
2. Always force-fetching `sigrefs` from remotes into the staging copy.
3. Making sure that sigref updates are fast-forward before transfering
   the remote into the production copy.
2023-05-03 16:16:34 +02:00
Slack Coder 0bfc3f59ee
cli: Auth without ssh-agent
Avoid having ssh-agent a hard dependency of `rad-auth`.

Only add the user's key in `auth::init()` to ssh-agent if it is running,
instead of exiting with error.

For `auth::authenticate()` which is used to authenticate the user with
Radicle, assume using `RAD_PASSPHRASE` is a fallback authentication
method.  If ssh-agent is not-detected, verify the RAD_PASSPHRASE is
present and correct.  Treat neither being present as an error.

Support this by clarifying on `ssh::agent::connect()`s error which are
due to it not being present.
2023-05-03 15:52:33 +02:00
Alexis Sellier 649d59f143
cob: Include head in initial patch entry in DAG
This change ensures that we include as a parent to the initial commit
of a patch COB, the head of the branch we are proposing as a patch.

This was already happening for patch updates, but we forgot to also
include it for the initial patch revision.

This ensures that the code is always fetched alongside the patch.
2023-05-02 09:18:17 +02:00
Slack Coder b004fd8afb
rad-issue: Correct formatting 2023-04-28 16:08:44 +02:00
Fintan Halpenny 0e6fae5a03
cli: test the deletion of cobs
Ensure that the deletion of cobs is respected by testing a scenario
where a peer creates and then deletes an issue, while another peer
fetches and also has the issue be present and then removed.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-28 14:28:46 +02:00
xphoniex ac12a4deee
cli: Implement `rad node start` with support for deamonizing
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-04-28 14:19:20 +02:00
Slack Coder 2667569a6d
cli: Fix patch open/update when out-of-sync
Trying to open or update Patch will fail if the user's working copy is
out of sync with the Radicle projects canonical head.

Fix this by always operating on the storage when opening or
updating a patch.
2023-04-28 10:33:36 +02:00
Vincenzo Palazzo 730eaa00ca
cli: Improve `rad issue show` output
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-04-27 11:48:11 +02:00
Alexis Sellier 60fc50644f
cli: Fix `Message::get` bug
We were not propagating the error properly.
2023-04-27 11:22:44 +02:00
Alexis Sellier 0ecd8fb074
cli: Add `--draft` to `patch list` command 2023-04-27 10:54:19 +02:00
Alexis Sellier 12a91bd0ae
cli: Create `rad patch ready` command
Allows for converting patches to and from draft mode.
2023-04-26 16:53:24 +02:00
Alexis Sellier f111681dd6
cli: Add `--quiet` option to `patch open` 2023-04-26 16:42:58 +02:00
Alexis Sellier 182c9592c0
cli: Add `--draft` flag to `rad patch open`
Allows opening patches as drafts.
2023-04-26 13:47:43 +02:00
Alexis Sellier 3b20d45d80
cli: Display patches like issues, in `rad patch`
We also make sure not to bail if one of the patches fails to load.
2023-04-26 12:29:32 +02:00
Alexis Sellier b809bd3d73
cli: Force push refs on patch open/update
This ensures that `patch update` does not fail in a non-fast-forward case.
2023-04-26 12:29:32 +02:00
Alexis Sellier 3a9c8b7144
radicle: Remove `delegate` from `Remote` type
It wasn't being set correctly, and it's not the place for it,
so we remove it and set it in `httpd`.

Note that `Remote` is now simply a wrapper around `SignedRefs`.
If we want to remove the type or turn it into an alias, it will
require touching lots of different parts of the codebase. I opted
not to do that here as it's lower priority.
2023-04-26 11:06:55 +02:00
Alexis Sellier 7a08a1d459
cli: Get fetch after track working
When tracking a repository with the `--fetch` option, we run a fetch
once the tracking is done.

When tracking nodes, we don't accept the `--fetch` flag, as there may
not be a repository to fetch.
2023-04-26 09:49:37 +02:00
Vincenzo Palazzo 8d1bf9e997
cli: Show a message when there are no issues to display
This commit fixes the inconsistency with the `rad patch` command,
which previously displayed an empty table when there were no issues. Now,
the CLI will display a message indicating that there are no issues to display.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-04-26 00:58:09 +02:00
Alexis Sellier 3ea7541d55
cli: Replace seedling emoji with alien invader
To match the new branding, we remove seedlings and sometimes replace
them with alien invaders.
2023-04-25 12:47:36 +02:00
Alexis Sellier 7d72b16087
cli: Call `rad sync` on `git push rad`
Instead of `Node::announce_refs`, we call `rad sync` to have the
terminal block while waiting for nodes to fetch the changes.

We also change the use of `git push` in the patch command to not
trigger syncing in that case.
2023-04-25 12:46:25 +02:00
Alexis Sellier 6346931ce2
cli: Add canonical remote to `init` and `checkout`
Add a remote that points to the canonical upstream.
2023-04-24 15:42:00 +02:00
Alexis Sellier d6cebf613f
cli: Remove `rad fetch` command
The command is replaced with `rad sync --fetch`. Soon, it will be called
from the git-remote-helper, so users won't have to call it explicitly.
2023-04-24 14:19:31 +02:00
Alexis Sellier a285943166
cli: Remove `rad push` command
Users should use `git push` or `git push rad` instead.
2023-04-24 14:19:24 +02:00
Alexis Sellier 671c169244
node: Implement `rad sync` command
This command announces refs to peers and waits for them to be
in sync.

Adds a subscribe method to `Handle` so that we can get the events
from the seed to allow us to confirm that the configured seeds fetched
from us.
2023-04-24 11:39:37 +02:00
Alexis Sellier 86feebe4d8
cli: Add `--quiet` flag to `rad issue` 2023-04-24 11:29:42 +02:00
Vincenzo Palazzo 5a4d0fff3f
tests: add radicle command test for the rad remote
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-04-22 14:10:23 +02:00
Vincenzo Palazzo d55861572d
cli: accept from the cli the remote subcommand
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-04-22 14:09:30 +02:00
Vincenzo Palazzo fb44af9653
cli: implement the rad remote rm command
Implementing the `rad remote rm` command in order to be able
to remote a remote inside the radicle remote list.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-04-22 14:09:30 +02:00
Vincenzo Palazzo 027ccb943e
cli: implement the rad remote list command
Implementing the `rad remote list` command in order to be able to
list all the radicle remotes added to the repository

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-04-22 14:09:30 +02:00
Vincenzo Palazzo 33547c9c3c
cli: implement the rad remote add command
implementing the `rad remote add` command in order
to be able to add rad remotes from the command
line.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-04-22 14:09:30 +02:00
Vincenzo Palazzo 0468a1a757
rad: preparation for the rad remote commands
This commits introduces just a couple of helper functions in order
to work with the `rad remote *` commands.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-04-22 14:09:30 +02:00
Alexis Sellier 442e8a7128
cli: Cleanup patch examples a little 2023-04-22 13:59:18 +02:00
Alexis Sellier ff56843fcc
cli: Render `rad issue list` with a nice table 2023-04-22 13:59:18 +02:00
Alexis Sellier 2ff5ad97f3
cli: Error out if we wrongly pass a `<patch-id>`
It was previously possible to call `rad patch open` with a patch-id
and get no error. This fixes it.
2023-04-22 13:57:58 +02:00
Alexis Sellier 9fd3527196
cli: Add `--tag` option to `rad issue open`
Also include a simple script for importing GitHub issues.
2023-04-21 11:10:07 +02:00
Alexis Sellier 6f17a4db67
cli: Don't show patch diff by default
It can be re-enabled with `-p`, which is what git uses usually.
2023-04-20 16:56:06 +02:00
Alexis Sellier 04e95b45fc
cli: Fix verdict output in patch timeline 2023-04-20 16:56:06 +02:00
Slack Coder 11d10b4e47
cli-test: Support '[..]'s which preserve spacing
By mapping all '[.. ]'s  with any number of spaces inside them into
'[..]'s, examples can preserve text formatting while using this glob
pattern.

The downside is failed output will show '[..]' in place of the original
version with spaces.
2023-04-20 16:52:20 +02:00
Fintan Halpenny 75bf7beedd
cli: add verbose flag to rad ls
A repository may fail to load when trying to run `rad ls`, but the
failure will be hidden from the output.

Add a `--verbose` flag to add warning information to stdout when a
repository fails to load.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-20 16:31:05 +02:00
Slack Coder bd04826223
Fix `rad --version` output
Write `rad --version` on its own line.
2023-04-19 09:08:59 -05:00
Fintan Halpenny f26adabdbf
cli: add rad fork example test
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-19 12:58:18 +02:00
Fintan Halpenny 3b49a7911b
cli: add rad fetch example test
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-19 12:58:18 +02:00
Fintan Halpenny ea03e8a38b
cli: add rad fork command
Add a `rad fork` command to create a forked namespace, using the local
peer, for the given repository.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-19 12:58:18 +02:00
Fintan Halpenny 92a14b671f
cli: use Doc::canonical in rad inspect
A project may exist within storage without the local operator not
having a fork of the project.

Use Doc::canonical in rad inspect to retrieve the canonical identity
document for use during inspection.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-19 12:58:18 +02:00
Slack Coder 327ebd4d2a
cli: remove unused cli::git methods
The methods appear not to be called anywhere.
2023-04-19 12:56:02 +02:00
Slack Coder 82d190f64f
cli: fetch if commmit missing when `rad merge`ing
Reduce friction when merging patches by automatically fetching the
Patch's commit head if its missing.

The calls git directly due to difficulties fetch the revision
anonymously with existing method.  Its important to fetch the commit
anonymously to remove dependency on how the local 'git remote's are
configured.
2023-04-19 12:56:02 +02:00
Slack Coder 3e87e5f9eb
cli: reduce `rad ls` dependency
Fetch project information using the delegates fork of the project.  This
avoids expecting a user's fork to exist locally.

Delegate project information is expected to remain in sync.
2023-04-19 12:50:07 +02:00
Slack Coder d79e97cf3b
cli: Note '--version' output as API
Consider our command line version output part of our API via a function
comment.

Test the first two fields of the version output are the program name and
a semantic version.
2023-04-19 10:35:20 +02:00
Alexis Sellier 94bef61944
node: Return only remotes that were fetched from
Instead of returning the namespaces that we fetched with,
we return the remotes that were actually fetched from.

This can differ if some trusted peers were not available
on the remote node.

Previously, if that was the case, it would cause errors
since the remotes were looked up and that lookup failed.
2023-04-17 18:58:56 +02:00
Alexis Sellier 992878fab4
cli: Update `rad untrack` command
This command was using very old code that needed updating.
2023-04-14 13:54:33 +02:00
Alexis Sellier eecea67ffd
cob: Deduplicate change parents 2023-04-14 13:54:27 +02:00
Alexis Sellier 97f076e3cf
Include dependencies for certain COB actions
We ensure that for example, the given commits are fetched before the
revision or merge actions in a patch.
2023-04-14 13:22:10 +02:00
Alexis Sellier 9db63a8801
cli: Cleanup patch, checkout and clone output
Remove extra whitespace, start moving away from sprout.
2023-04-12 12:02:38 +02:00
Alexis Sellier 89b9eb53b7
node: Implement protocol multiplexing
To improve the reliability and flexibility of the protocol, we introduce
multiplexing over peer connections. This involves a new `Frame` type
that carries a stream-id and payload.

Three stream types are made available:

1. Control
2. Gossip
3. Git

This change brings the following improvements:

* Removed need to queue fetch requests
* Removed need to queue gossip messages
* Removed need for `Fetch` and `FetchOk` messages
* Service doesn't need to know about inbound fetches
* Removed one round-trip for fetch negotiation
* Removed special `done` git packet
* Removed session logic and state around Git/Fetch protocols
* Removed code around upgrading/downgrading transport
* Worker in responder mode is able to process any number of fetches
* Connections support any number of concurrent fetches

We had to introduce a few extra things however to make it all work:

* A `VarInt` type for variable-length integers, since we want the frames
  to be lightweight.
* A custom "tunnel" implementation, since we couldn't use the existing
  one anymore.

Overall the change removes more complexity than it adds, while improving
the protocol along the way.
2023-04-10 14:41:55 +02:00
Adam Szkoda 0f47dc9057
cli: Make `rad rm` work without a fork 2023-04-10 10:42:22 +02:00
Alexis Sellier 3d40a606f7
cli: Fix `rad track` help output
Even though we accept `did:key` as a substitute for NIDs, we don't
generally accept DIDs in this command.
2023-04-10 10:28:46 +02:00
Alexis Sellier c1face7cd8
cli: Fix and simplify `rad review`
* Properly remove review help message from review
* Remove `--no-confirm` and confirmation step

The CLI should be mostly non-interactive for day-to-day commands,
keeping the interactivity for the TUI.
2023-04-10 10:27:52 +02:00
Alexis Sellier f999a62da2
cli: Show patch status in color in `patch show` 2023-04-10 10:17:38 +02:00
Alexis Sellier 7d1e3d489b
cli: Add `patch archive` sub-command 2023-04-10 10:17:37 +02:00
xphoniex 414477a316
cli: Unify format of help messages
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-04-10 10:06:45 +02:00
Alexis Sellier 33461e4be1
Set patch status to `merged` automatically
When a merge is applied to a patch, we check whether the threshold
of delegates has been reached, at which point we set the patch status
to `merged`.

This requires threading the identity document oid through the "apply"
process.
2023-04-05 10:32:45 +02:00
Alexis Sellier 6b44955cd9
cli: Show timeline in `patch show` 2023-04-04 21:19:50 +02:00
Alexis Sellier 9e50d9053a
cli: Additional fixes in the merge process 2023-04-03 16:06:24 +02:00
Alexis Sellier b6fa4a4b2a
cli: Some improvements to `rad merge` 2023-04-03 16:06:24 +02:00
Alexis Sellier cf37950828
node: Rename control socket
The old name, `radicle.sock` didn't tell us much about the purpose
of this socket.
2023-03-31 17:29:58 +02:00
Slack Coder 0b7f169c8b
cli: Support revision id in `rad merge`
Revision IDs are globally unique.  Users will be able to use the
Revision ID in place of its patch ID.

Make `rad merge` refuse to merge an older revision unless the `--force`
option is given.
2023-03-31 17:24:55 +02:00
Sebastian Martinez 87f47cdc67
Reduce pub accessors in patch and issue cob structs
Replaces pub accessors to struct fields with methods
Also creates some methods to compute necessary information

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-31 13:44:37 +02:00
Alexis Sellier 973f618cd3
node: Fix routing table update on refs
The announcer is always the one who must have the refs, not the relayer.
This was changed in a recent patch.
2023-03-30 10:24:09 +02:00
Alexis Sellier 7c41c5edff
node: Replace most sleeps with events
With the new event system, we can replace the thread sleeps by
waiting for events. This should speed tests up a lot and
be more reliable.
2023-03-30 10:24:06 +02:00
Alexis Sellier 6fb6cff708
term: Add border support for tables 2023-03-27 17:46:32 +02:00
Alexis Sellier 8dba01d6ae
cli: Improve patch command output
* Fix timeline ordering
* Remove spinner noise
* Add revisions to timeline
2023-03-24 13:04:52 +01:00
Alexis Sellier 577a232a68
cli: Fix multiline `patch show` description output 2023-03-23 14:43:21 +01:00
Alexis Sellier 6c1e2d0ddd
cli: Don't strip initial message from editor
This was problematic when the initial message was a valid default.
2023-03-23 14:43:21 +01:00
Alexis Sellier 63fc06c817
cli: Don't have blank line if no description
Changes `rad patch show` to not have a blank line when there is no
description.
2023-03-23 14:43:21 +01:00
Sebastian Martinez 8e3b629178
cli: Enable `rad tag` and `rad untag` for patches as well
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-03-23 11:53:11 +01:00
Vincenzo Palazzo 654a21b2b3
cli: Allow git revision parameters as COB IDs
This commit allows any git revision to be used instead
of the full SHA-1, when specifying COBs.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-03-22 15:38:14 +01:00
Adam Szkoda b4c3bee39d
cli: Add CLI commit SHA-1 to help 2023-03-22 08:52:35 +01:00
Alexis Sellier db8ec5735f
cli: Use new widgets for `patch list` 2023-03-21 12:43:44 +01:00
Alexis Sellier ab74e54949
term: Implement new output widget system
We implement a new `Element` trait which allows for more complex output
to be drawn, such as vertical and horizontal stacks.

We adapt `Table` to work within this system.

We refresh the output of `rad patch show` to use these new tools.
2023-03-21 12:43:44 +01:00
Slack Coder b6c1560a0a
cli: add workflow example with two peers
Make the documentation more realistic by using two peers, a maintainer
and a contributor, for the client examples.  Define them as 'workflow'
examples, ordering them in their own directory to aid user navigation.
2023-03-20 18:27:58 +01:00
Alexis Sellier 5ccf38079c
cli: Make `patch checkout` fetch missing objects
Before this change, `rad patch checkout` would fail if the patch commits
were not in the working copy.
2023-03-18 12:24:17 +01:00
Alexis Sellier 8f57d60706
cli: Don't rely on working copy for `patch show`
Since the patch may not have been pulled into the working copy,
we shouldn't rely on it for displaying patch information.
2023-03-18 12:24:17 +01:00
Alexis Sellier cf1acf7e24
Fix patch `description` method
The description is not actually optional, so don't return an `Option`.
2023-03-18 12:24:17 +01:00
Alexis Sellier bd436d4369
cli: Open tracking DB in read-only mode 2023-03-15 12:59:49 +01:00
Alexis Sellier caaa7581e6
node: Remove `Routing` command
Replaced by direct DB access.
2023-03-15 12:59:49 +01:00
Alexis Sellier b558c742e6
node: Rename `repo_entries` to `repo_policies`
Do the same thing for `node_entries` etc.
2023-03-15 12:59:49 +01:00
Alexis Sellier 9b6ede8fc5
cli: Use tracking DB access for `node` command 2023-03-15 12:59:49 +01:00
Alexis Sellier 13998dcf46
cli: Flesh out `rad self` 2023-03-15 10:25:23 +01:00
Alexis Sellier 9c77332cba
cli: Implement `tag` and `untag`
These commands are added at the top level because they will eventually
also work on patches.
2023-03-13 15:08:14 +01:00
Alexis Sellier 2737369910
cli: Fix missing patch announcement 2023-03-13 14:37:01 +01:00
Alexis Sellier f7aac06a8f
cli: Polish `assign` and `unassign` commands 2023-03-13 12:27:47 +01:00
Alexis Sellier 8e5627d28a
node: Rename `tracked_repo` -> `repo_policies`
I was finding the current naming misleading, as the returned entries
could be for blocked repos/nodes.
2023-03-13 11:41:07 +01:00
Alexis Sellier b33fb2a33d
cli-test: Improve testing framework logging
Show which file is being run.
2023-03-13 11:38:33 +01:00
Vincenzo Palazzo f8aa1daedb
cli: show the issue when it is created
Show the issue when it is created to give feedback to the user.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-03-12 19:26:28 +01:00
Slack Coder 166f7e7cc2
cli: Minimize patch info on creation
Reduce noise when showing patch information to the user on creation by
only showing the git branch name and not the commit reference.
2023-03-11 18:38:54 +01:00
Alexis Sellier 34a2d1a9dc
cli: use canonical head for patch target
Correct assumptions made about how patching work in `rad patch`.  Make
the default Patch target a `git ref` in place of a target 'peer'.

Use the canonical head as the git reference.  This is head of the
project's master branch which project delegates have concensus on.
2023-03-11 18:38:54 +01:00
Alexis Sellier aacacf872f
cob: Use `EntryId` as the operation identifier
By introducing a small limitation: only allowing entries in the change
graph to be addressable, instead of individual operations; we
drastically simplify the CRDT implementation.

There are four advantages:

1. Op ids are just regular SHA-1s
2. There's no need for relative IDs, ops never refer to other ops within the
   same commit
3. There's no need for a nonce, since commits can't collide, and neither can op IDs
4. `OpId` can just be an alias of `EntryId`

The disadvantage of course, is that we have to be mindful of how we
create op transactions, since each transaction creates an addressable
unit. For example, we must not include multiple patch revisions in the
same transaction.
2023-03-09 17:08:56 +01:00
Alexis Sellier adbf6f5bf5
cli: Improve `patch` command
Cleanup and simplify output of patch command.
2023-03-08 20:23:49 +01:00
Alexis Sellier 1168f2ddb5
cli: Update `track` command
Allows the `track` command to be used to track nodes and repos.
2023-03-08 15:32:34 +01:00
Fintan Halpenny 1e8f5b2259
node: determine fetching namespace based on repo policy
To determine the correct Namespaces to use, the repo Policy and Scope
are consulted.

If the policy is Block then this is a failure state and is reported to
the other end.

Otherwise, if the policy is Track, then the scope is checked. For the
Trusted Scope then the Namespaces should consist of all tracked nodes
and delegates for the given repository. However, the repository might
not exist and so it is necessary for the whole repository to be
fetched.

For the All Scope, all Namespaces are fetched.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 11:33:41 +00:00
Fintan Halpenny 3b015a9325
radicle: accept Scope as track_repo argument
The method `track_repo` only accepted the RID as the argument for
tracking.

Instead, allow passing Scope as an argument for tracking a
repository.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 11:29:34 +00:00
Fintan Halpenny b82584617b
node: store Scope in tracking config
The tracking configuration has no way of consulting for a configured
scope.

This change allows the storing of this scope inside the tracking
`Config` -- currently unused.

The default Scope is chosen as Trusted, so that nodes do not
implicitly track any other node. If this behaviour is desired -- for
example, for seed nodes -- then All should be chosen.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 11:29:34 +00:00
Fintan Halpenny 39be7db1e9
radicle: make alias optional
Previously the alias field was simply a string which could possibly be
empty. Some checks were made to see if this string was empty.

Instead, make the logic more obvious by making the alias field
optional.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-08 11:29:34 +00:00
Vincenzo Palazzo 0e491fae79
cli: fix command line silent abort
Fix the command line silents abort when the
the `EDITOR` variable is not specified.

With this commit the result is reported below

```
➜  rio git:(main) RAD_PASSPHRASE=12345 rad issue open
✗ Issue failed: editor not configured: the `EDITOR` environment variable is not set
```

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-03-08 12:25:11 +01:00
Alexis Sellier c3a5aced07
node: Handle case of crossing fetch requests
It is possible for a pair of nodes to concurrently ask each other
to fetch some repo. These "crossing" requests are problematic,
because the nodes end up waiting for each other to reply, and
the reply never comes.

With this change, the node pair agrees on proceeding with one of
the fetches, while canceling the other.
2023-03-07 16:22:22 +01:00
Fintan Halpenny ad63583bee
cli: rad node example
Tests the rad node CLI subcommand.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-07 15:38:41 +01:00
Fintan Halpenny ed985f6fe0
cli: rad node
This adds a rad node subcommand to the CLI.

The subcommand aims to fulfill the following requirements:

- Checking the node status (rad node status)
- Connecting to the node's control socket (rad node connect)
- Printing out our routing table (rad node routing)
- Printing out our tracking policies (rad node tracking)

The following are yet to be implemented:

- Starting the node (rad node start)
- Stopping the node (rad node stop)

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-03-07 15:38:41 +01:00
Alexis Sellier 5fb5df2e61
cli: Update `inquire` crate 2023-03-07 10:39:45 +01:00
Alexis Sellier 85df613682
cli: Implement automatic issue announcement 2023-03-07 08:40:20 +01:00
Alexis Sellier cb3b7a3765
cli: Implement `patch delete` 2023-03-06 15:45:54 +01:00
Alexis Sellier 9000a626d7
Use commit oid for COB parent
We were using the blob oid, which was causing the commit tree to
be invalid.
2023-03-06 15:39:34 +01:00
Alexis Sellier fb2c388a5d
cli: Properly trim `patch` message 2023-03-06 15:39:07 +01:00
Alexis Sellier 35f22ba37a
cli: Update `init` help for consistency 2023-03-06 15:38:42 +01:00
Alexis Sellier be5c9c9258
cli: Add `--verbose` flag to `init` 2023-03-06 15:38:42 +01:00
Alexis Sellier c8c44c884c
cli: Allow `init` without running node 2023-03-06 15:38:42 +01:00