Commit Graph

576 Commits

Author SHA1 Message Date
cloudhead c8afda2ddf
cli: Don't discard radicle-node stderr output 2024-01-10 15:23:08 +01:00
Fintan Halpenny 8e0e1c232d
cli: improve Author labels
When an alias cannot be found for an `Author` the DID can be repeated eg.

    ✓ accepted by z6MkkfM…jXVsVz5 z6MkkfM…jXVsVz5

To prevent this we output one of four cases:

* `(<alias>, (you))` -- the `Author` is the local peer and has an alias
* `(<did>, (you))` -- the `Author` is the local peer and has no alias
* `(<alias>, <did>)` -- the `Author` is another peer and has an alias
* `(<blank>, <did>)` -- the `Author` is another peer and has no alias

Notably, we output a blank `Label` when no alias was found.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-01-09 13:44:46 +01:00
cloudhead 7d4ce8207d
httpd: `rad web --connect` takes an argument
To be able to connect to any running httpd, have `--connect` take the
address of the running daemon.
2024-01-09 13:33:26 +01:00
Fintan Halpenny b57099a0d0
cli: allow editing patch revision descriptions
Allow `rad patch edit` to take a `--revision` option which will edit
the description of the specified revision, rather than the root
revision.

If the flag is not specified, then the original behaviour of editing
the root revision's title and description is used.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-01-09 13:28:08 +01:00
Fintan Halpenny a8cca57c0a
cli: inline patch revision updates
Instead of having a timeline of a patch be global and sorted by
timestamp, organise it via revisions. Each revision has an entry in
the timeline, sorted by timestamp. Under each revision, a series of
updates are inlined, also sorted by their timestamps. Currently, these
updates can either be reviews or merges.

For example:

```
├────────────────────────────────────────────────────────────────────────────┤
│ ● opened by fintohaps (you) 1 week ago                                     │
│   └── ✓ accepted by fintohaps (you) 1 week ago                             │
│ ↑ updated to 5f2a123e3f2aa60f2e03815df283563495b73085 (a1c3c0f) 1 week ago │
│   └── ✓ accepted by fintohaps (you) 1 week ago                             │
│   └── ✓ merged by cloudhead (z6Mkt67…v4N1tRk) now                          │
╰────────────────────────────────────────────────────────────────────────────╯
```

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-01-09 13:06:03 +01:00
Fintan Halpenny 3323082ce3
cli: show debug for patch and issue
It's useful to be able to print out the Rust data of a Radicle defined
COB for debugging purposes, since the current CLI commands will only
show a subset of the data.

Add `--debug` flags to `rad patch show` and `rad issue show` that
print the data to stdout.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-01-09 11:09:05 +01:00
cloudhead 6349c1c559
cli: Small change to output for clarity
So that users don't confuse the revision id with a commit id, we
explicitly state it's a new revision id.
2024-01-08 17:46:22 +01:00
Fintan Halpenny 9f9df6264e
cli: prevent identical revision for `rad patch update`
Prevent `rad patch update` to create an identical revision to any
other revision in the patch, rather than just the latest revision.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-01-08 17:35:32 +01:00
cloudhead e4f06e9c9d
cli: Improve `rad remote add`
By default, this command now:
* Follows the peer if not already followed
* Syncs refs of the peer, if it wasn't followed before
* Fetches refs into working copy

This functionality can be disabled via `--no-sync` and `--no-fetch`.
2024-01-08 17:28:01 +01:00
cloudhead 3a3820b06d
cli: Disallow patch checkout unless matching
Instead of quietly switching to an old commit, error out if we can't
checkout the patch without overwriting the existing branch.
2024-01-08 13:10:17 +01:00
cloudhead 7169e97bd5
cli: Tell the user when canonical head is updated
This is useful especially in multi-delegate repos, since patches can be
merged without the head being updated.
2024-01-05 12:09:30 +01:00
cloudhead 6bc7d297a5
cli: Fix `inspect` command for non-delegates
Since non-delegates don't have `id` COBs, don't rely on it.
2024-01-05 11:43:26 +01:00
cloudhead 59c101fc59
cli: Suggest correct command for pushing
In cases where there is an existing remote, the user has to specify the
branch name when pushing, so we update the help string to suggest that.
2024-01-05 11:03:24 +01:00
cloudhead 91684cc9ca
cli: Add `rad patch diff` command 2024-01-04 11:49:01 +01:00
cloudhead 04bfbca15d
cli: Support `--seed` on `rad clone`
Allows specifying one or more seeds to clone from. This is useful for
cloning private repositories which are not in the routing table.
2024-01-03 14:07:19 +01:00
Fintan Halpenny 3cf51043b3
cli: list tracked and untracked remotes
Add functionality for lising the remotes that are in the storage
repository, but a working copy remote has not yet been created for
them.

This functionality is included in the `rad remote` command since it
can be directly used for creating Git remotes using the same command,
i.e. `rad remote add`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-01-02 15:23:08 +01:00
Fintan Halpenny e3b3f3c4f4
cli: move seeding behaviour to `rad seed`
To keep behaviour consistently under subcommands, move the `rad node
seeding` behaviour under `rad seed`. When an `<rid>` isn't
provided then the seeded repositories are listed.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-01-02 15:23:08 +01:00
Fintan Halpenny f6e2de30ca
cli: move following behaviour to `rad follow`
To keep behaviour consistently under subcommands, move the `rad node
following` behaviour under `rad follow`. When an `<nid>` isn't
provided then the followed nodes are listed.

This includes filtering by alias, when `--alias` is used.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-01-02 15:23:08 +01:00
Fintan Halpenny 6baefdb13f
cli: use `git` for anonymous fetch
Shell out to `git`, avoiding using `git2`. This is to avoid an
issue where somewhere within the fetch there is an attempt to lookup a
`rad/sigrefs` object, which says that the object is missing. It is
suspected that this is due to the object being localised in the same
packfile as other objects we are fetching. Since the `rad/sigrefs`
object is never needed nor used in the working copy, this will always
result in the object missing. This seems to only be an issue with
`libgit2`/`git2` and not `git` itself.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-01-02 15:04:49 +01:00
cloudhead 79c1fb309e
cli: Allow merging patch drafts 2024-01-02 14:54:20 +01:00
Sebastian Martinez 1bb400c278
httpd: Add edits field to revision json 2023-12-22 15:17:25 +01:00
Sebastian Martinez ee3dcfacf0
httpd: Allow edit revision embeds 2023-12-22 15:09:20 +01:00
Sebastian Martinez a3a8060e5c
radicle: Add `Vec<Edit>` to revision description
This allows us to have embeds on a patch revision, and eventually also
show the edits that have been made to a revision description.
2023-12-22 15:08:35 +01:00
Sebastian Martinez 1f36879aa2
cob: improve Comment generics
`Infallible` is a more appropriate type in comparsion to `()` for
comments that do not require a `CodeLocation`.

That is because if the type for `location` is `Option<()>`, this means
that `Some(())` can be constructed, however, we never intend to
construct that variant. On the other hand, `Infallible` can never be
constructed, and so, only `None` can be used.

This requires updates to some functions to use the generic `T` and
also handle the different kinds of `Comment`s -- `Infallible` and
`CodeLocation`.

X-Co-Authored-By: Fintan Halpenny <fintan.halpenny@gmail.com>
2023-12-22 14:09:02 +01:00
cloudhead 48843434c7
cli: Support colors in git helper output 2023-12-22 12:15:34 +01:00
cloudhead c94df2d5cd
node: Make inventory announcements more robust
Allow some margin of error when sending multiple inventory announcements
at a time. Previously, they might end up with the same timestamp, so
only the first announcement would be processed by nodes. Now, we ensure
that the timestamp is updated.
2023-12-20 15:44:02 +01:00
Fintan Halpenny f9d9bdf8cd
cli: fix update hint
The hint for updating a patch incorrectly printed:

    git push rad -f HEAD:rad/patches/<patch id>

The remote, `rad`, is already specified so the the right hand side of
the refspec should only be `patches/<patch id>`.

Fix this by stripping the remote from the name of the branch in the
remote helper.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-12-20 15:10:13 +01:00
Fintan Halpenny 48aa725bea
cli: Add `--base` option to `rad patch update`
Allow the CLI user to update a patch's base commit through the `rad
patch update` command.

There was check to see if the head of the branch was the same as the
head of the revision, which would result in the update being skipped.
This was adapted to check that the head *and* the base were the same.

A test was added in the examples to showcase this use.

Signed-off-by: Fintan Halpenny <Fintan Halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-12-19 15:00:27 +01:00
Fintan Halpenny f90421a6bb
cli: sync on patch and issue updates
When we perform updates to cobs we tend to want to sync those changes
to the network after. This patch automatically does this for
operations that perform updates to issues and patches.

Note that `--announce` becomes the default for the `rad patch`
command.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-12-19 14:19:55 +01:00
cloudhead 13db55014b
cli: Show URL on `rad init` 2023-12-19 14:15:30 +01:00
cloudhead 6eb2772235
node: Improve flexibility of test environment
Allows us to pass full configs (profile or node) when creating test
nodes or profiles.
2023-12-19 14:15:30 +01:00
cloudhead 67c950954d
cli: Improve `rad sync status` output
To make it less confusing, clearly mark the local node and don't show
sync status for it.
2023-12-19 14:14:11 +01:00
cloudhead 5e3990d411
cli: `rad ls` shouldn't show unseeded by default
Unseeded repos should not show up in `rad ls`, by default. Only with
`--all`. We also use a special visibility of "local" for those projects.
2023-12-19 14:14:11 +01:00
Fintan Halpenny 070e912b3e
cli: allow directory in rad clone
Allow the user to specify a directory to clone into when
performing `rad clone`.

Signed-off-by: Fintan Halpenny <Fintan Halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-12-14 10:52:04 +01:00
cloudhead c761d03a5a
cli: Review builder fixes
Diff hunks were not being applied properly due to the line offsets
changing when a hunk was skipped.
2023-12-14 10:50:38 +01:00
cloudhead 9ada30255b
cli: Don't sync on git-fetch
It's actually not such a great idea to sync on git-fetch and
git-ls-remote, as syncing is supposed to happen in the background
already, and if you want to force a sync, you can just call `rad sync`.

Previously, it would be annoying that when you called `rad sync` and
then `git fetch`, it would still attempt another sync, for example.

Moving forwards, it might make sense to call `git-fetch` on `rad sync`
(so the other way around), because `git-fetch` is free (it doesn't talk
to peers), and you almost always want your working copy up to date with
your storage.
2023-12-13 14:47:14 +01:00
cloudhead cc380532c6
cli: Improve messaging when config doesn't load
Instead of telling users to setup their profile, point out the actual
problem with the config.
2023-12-13 12:30:11 +01:00
cloudhead 87debf380e
cli: Improve passphrase handling
Reduce redundancy in passphrase functions and give better error message
when not using a TTY.
2023-12-13 12:29:12 +01:00
cloudhead ebee41fbf1
cli: Only allow shell-friendly characters in names 2023-12-13 12:29:12 +01:00
cloudhead 376c3caca0
cli: Fix small clippy issue that snuck in 2023-12-13 12:27:49 +01:00
Fintan Halpenny 44206cb6ca
cli: ensure patch is present in rad-push-and-pull-patches
In some cases, there's a chance for the patch to not have arrived
before trying to check it out in the `alice` repo.

Ensure that the patch is present by first running `rad sync -f`.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-12-13 12:25:12 +01:00
cloudhead d773659d66
cli: Don't fork on clone
Since forking creates your `rad/sigrefs`, which then needs to be backed
up forever, we avoid forking on `rad clone`. This should make little or
no difference for users, as the "fork" will be created on `git push`.
2023-12-13 12:14:06 +01:00
cloudhead ecb59d687b
cob: Return `RevisionId` instead of `Revision`
Previously we panicked if a revision wasn't found after an update. But
it can happen that the update goes through yet a concurrent update
prevents the revision from being valid.

To partially deal with this, we don't try to lookup the revision after
an update, we simply return the ID. This means a subsequent lookup can
fail, and the error can be handled there.
2023-12-13 12:14:06 +01:00
cloudhead 57e3b2a154
cli: Add timeout option to `rad watch` 2023-12-13 12:14:06 +01:00
cloudhead 0e8a64d0f8
cli: Better handling of missing refs in `watch` 2023-12-13 12:14:06 +01:00
cloudhead 74a0d7a4d2
cli: Fix `rad seed --delete` command
There was a bug due to `--delete` not being treated properly as a
sub-command.
2023-12-12 11:02:07 +01:00
cloudhead 472a1e6545
cli: Add `watch` command
Allows watching and waiting for refs to change. This is especially useful for
tests. For now, we don't show it in the output of `rad`.
2023-12-11 12:04:26 +01:00
cloudhead 5af8f70665
cli: Fix `rev` argument parsing
We were using the `oid` function incorrectly, which has been changed
to actually return an OID.
2023-12-11 12:04:26 +01:00
cloudhead 9aee9b2436
cli: Corrections to patch/issue help text 2023-12-06 12:07:31 +01:00
cloudhead 6ca7da2768
radicle: Rename many more methods using new naming 2023-12-06 10:02:00 +01:00