Commit Graph

1394 Commits

Author SHA1 Message Date
Fintan Halpenny 90f3a37a08
remote-helper: Accept revision for `patch.base`
When specifying a `patch.base` to point to for stacking patches, it's
useful to accept any kind of revspec, e.g. `HEAD^`.

Change the argument parsing to use the `Rev` type instead, and change
the `rad-patch-ahead-behind` to use `HEAD^` to test the example usage.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-10-30 15:20:39 +01:00
Fintan Halpenny 199fa07a79
radicle: Apply clippy suggestions
`cargo clippy --all --all-targets` is warning that there are multiple
redundant clones.

Apply the suggestions by removing the calls to `clone`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-10-30 14:51:21 +01:00
Fintan Halpenny 2584ecdb0a
radicle: Pin timestamp for testing
When testing the CLI, "since"-calculations will result in different
values over time:

    now
    1 month ago
    2 months ago
    10 months ago
    1 year ago
    10 years ago

Initially, the solution was to use the wildcard match from `snapbox`,
`[..]`, to match on these values. However, since these values change
in length it means that they will affect the width of the tables
produced by the CLI.

To ensure the width is stable across runs over time it's possible to
use a time that is the same as the commit time used at testing.

To do this the `Timestamp` type is now a newtype which has a
constructor `now` which will use the `RAD_COMMIT_TIME` env variable
for construction, if it's available and in debug mode. This ensure
that all "since"-calculations will result in `now`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-10-30 14:48:38 +01:00
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
cloudhead c99d9a6aed
radicle: Make mock transport thread-safe
The mock transport was not thread-safe when multiple threads used the
same node ids. This is fixed by including the thread id as part of the
storage key.
2023-10-11 14:53:59 +02:00
cloudhead bb3c1b5684
dag: Add "dot" format output 2023-10-11 14:53:59 +02:00
cloudhead 8657cd8fc8
dag: Add a few more tests 2023-10-11 14:53:59 +02:00
cloudhead 5709f5d886
cob: Improve stability of test setup
We employ various tricks to ensure that tests are reproducible.
In this case, having stable commit ids allows us to test specific
traversal orders of a COB history in cases of concurrent updates.
2023-10-11 14:53:59 +02:00
cloudhead 69fe1d5989
cob: Remove mentions of automerge 2023-10-11 14:53:59 +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 9a1a216f70
httpd: Add configuration to `/node` endpoint
Adds the "config" key containing node configuration.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-10-11 13:51:38 +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 7c842bcc1d
term: Use `\r` for spinner
The save/restore cursor escape sequences from `termion` do not work on
macOS.
2023-10-11 09:34:07 +02:00
Fintan Halpenny 499738de71
radicle: fix divergence check
The `graph_descendant_of` method is strict in that it will return
false if the two `Oid`s are equal -- they are strictly not
descendants.

If the `head` is the same as the `canonical_oid`, no error should be
returned and the `push` can happen without any issues.

Add a check for `head != canonical_oid` before the
`graph_descendant_check`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-10-05 12:31:37 +01:00
cloudhead cd4c44986a
node: Relax `routes_to` test function
We were being too strict by requiring that no routes existed that
weren't passed into the function. This isn't really useful for testing,
since we're more interested in checking that certain routes are there,
rather than testing that *only* those routes are there.
2023-10-04 14:37:29 +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
Sebastian Martinez 35da28d8af
httpd: Return entire files from commit handler
Used for syntax highlighting.

Also improves the handling of multiple parent commits, by adding all of
them.
2023-10-03 12:19:18 +02:00
Sebastian Martinez 313fc1315d
httpd: Increase body size limit for `/projects/*`
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-10-03 11:59:11 +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 a5a553815c
remote-helper: Be more consistent with errors
Since we don't control when this error is output, we stick to the more
common "error:" prefix, which can be shown in any order in the output.
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 883b548c61
Improve computation of canonical head
We employ a better algorithm for determining which commit should be
canonical when there are multiple possible options.

The algorithm still doesn't work in certain cases when there are
multiple merge commits as candidates, with shared parents.

We leave some (ignored) failing tests to be resolved in the future.
2023-09-27 12:25:14 +02:00
Sebastian Martinez 5acfffb352
httpd: Improve data-uri support
We were just using `strip_prefix` with a hardcoded value, which wasn't
able to adjust to URIs that start with `data:image/png` or other content
and types.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-09-26 17:33:06 +02:00
cloudhead e57dbc337a
scripts: Small fix for POSIX-compliance 2023-09-26 13:11:12 +02:00
cloudhead 1376ab63c0
cli: Allow checking out a specific revision
Allow `rad patch checkout` to specify a revision to checkout that may
not be the patch's latest.
2023-09-21 16:18:24 +02:00
cloudhead c94bd50666
cob: Better distinguish patch revisions
The `Patch` API and semantics are changed a little bit:

* It's now valid again to propose a revision without being the patch
  author.
* To get revisions by the patch author, `Patch::updates` is used.
* `Patch::latest` now only looks at revisions by the patch author.
* Added `Patch::revisions_by`, `Patch::authors` and `Patch::latest_by`.
* The merge behavior on git-push is improved to favor revisions that
  merge more recent commits. We also allow for merging the non-latest
  revision.
2023-09-21 13:51:55 +02:00
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
Sebastian Martinez 9df1922f15
httpd: Add routes for handling embeds in issues
Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-09-19 10:00:01 +02:00
Sebastian Martinez a3f460e67d
httpd: Add node alias to session endpoints
This will allow us to show the alias of an authenticated user in the web
client.

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
2023-09-18 11:18:17 +02:00
Alexis Sellier 1abce45d5d
node: Slightly increase rate limit defaults 2023-09-18 11:14:19 +02:00
Alexis Sellier a7cd7b25f5
node: Allow rate-limitting to be configurable 2023-09-18 11:14:19 +02:00