Commit Graph

444 Commits

Author SHA1 Message Date
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