Commit Graph

465 Commits

Author SHA1 Message Date
cloudhead 1d167581f2
cob: Introduce `xyz.radicle.id` COB
Introduces a new COB type to store repository identity documents.

The reason for this change is to:

1. Simplify the code, as the identity document logic resembled a COB,
   yet it had custom logic. This allows existing COB code to be used for
   identities.
2. Make identity document update logic more flexible, since COB actions
   can be added in the future.
3. Re-purpose existing tools around COBs to work on identities, eg. `rad
   cob`.
4. Unify the concept of an identity change proposal, with regular identity
   changes. This means we can remove the `id.proposal` COB in favor of
   using the `id` COB itself.

Notes
-----

* Each repository has one Identity COB.
* The `Proposal` COB has been repurposed into the `Identity` COB.
* Identity documents are stored as *embeds* inside the Identity COB
  actions.
* The action that contains new document versions is called `revision`,
  just like the Patches COB.
* The namespaced `rad/id` ref is a symbolic reference to that Identity
  COB.
* The canonical `rad/id` ref is a direct reference to the commit in the
  Identity COB that contains the latest *accepted* revision of the
  document.
* All commands for managing identities have been folded into `rad id`.
  Hence `rad delegate` and `rad edit` are removed.
* The concept of "rebasing" an identity document is gone.
* The `rad id` output has been updated to match the style of other
  commands.
* When a revision has enough signatures, it is automatically adopted as
  the current identity, there is no longer the need for a "commit"
  action.
* When an identity revision is proposed, and the current identity has a
  threshold of `1`, that identity is automatically accepted due to the
  above point.
* The idea of "verifying a peer's identity branch" no longer applies, as
  COBs cannot be verified one history at a time.
* Since the root commit of the Identity COB does not have a "Resource"
  to point to (it would have to point to itself, which is impossible),
  we've made the resource id optional for COBs.
2023-10-12 17:32:33 +02:00
dietrich ayala c3e11057ad
cli: Minor output improvements to `rad auth` 2023-10-11 14:49:37 +02:00
Lars Wirzenius b133785449
cli: Add `rad cob list` subcommand
This will be helpful when we add additional types of COB.

Signed-off-by: Lars Wirzenius <liw@liw.fi>
2023-10-11 14:44:32 +02:00
Sebastian Martinez 504a198cec
Update `radicle-surf` to v0.17
This commit introduces the `FileStats` struct, that adds the insertions
and deletions for each file to `DiffContent`.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-10-11 14:29:34 +02:00
Sebastian Martinez 78e6833672
httpd: Add missing COB actions
Handles missing issue and patch actions. Adds embeds to patch comments.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-10-11 13:36:48 +02:00
cloudhead 2011f2b06e
cli: Disable `html` highlighting by default
See code comment for reasoning. This is fixed in v0.20.0 which is not
out yet.
2023-10-03 13:33:10 +02:00
cloudhead 8479666731
cli: Disable `ruby` highlighting by default
See code comment for reasoning.
2023-10-03 13:18:10 +02:00
cloudhead 154566f8ef
cli: Update to `radicle-surf` 0.16 2023-09-27 15:54:16 +02:00
cloudhead b896a7fbeb
cli: Support working copy files in diff
Previously we only syntax highlighted files that were blobs inside the
git repo. This doesn't work when diffing files in the working copy.

We solve that by looking for files in the working copy if they aren't
found in the ODB.
2023-09-27 15:26:57 +02:00
cloudhead bb40347121
term: Change signature of `Constraint::from_env`
Return `None` if there's no terminal.
2023-09-27 15:17:07 +02:00
cloudhead 6a5753f4bc
cli: Add `--color` option to `rad diff`
Forces color output for eg. when piping into a pager.
2023-09-27 14:44:20 +02:00
cloudhead dc7e126c85
cli: Implement `rad diff` command
Works like `git diff`, using radicle's pretty diff output.
2023-09-27 13:31:20 +02:00
cloudhead 5442e6699d
cli: Split rev and oid parsing functions
* `args::rev` now parses things like `master`, `HEAD`, `3f25ea5`.
* `args::oid` is for parsing full or short oids, like `3f25ea5`.

Both return a `Rev`, since short oids can't be properly represented with
the `git2::Oid` type.
2023-09-27 13:20:48 +02:00
cloudhead 90fe50c152
cli: Implement pretty diffs with highlighting
Implements a new kind of diff output that includes syntax highlighting.
This type of diff will be used for code review.
2023-09-27 12:37:41 +02:00
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