Commit Graph

1039 Commits

Author SHA1 Message Date
Alexis Sellier 5ccd74aa8a
Use `tmp` namespace for temporary refs during push
The `refs/tmp` namespace is used by Git for the purpose of storing
temporary refs. We use it here instead of `refs/patch` to indicate
that the refs can be safely deleted.
2023-05-13 23:27:03 +02:00
Alexis Sellier 7d68df86d1
radicle: Only sign known refs
This change ensures that we only sign refs in known categories. This
prevents accidently signing a temporary ref or malformed ref.
2023-05-13 23:08:12 +02:00
Alexis Sellier 1f711b394a
term: Fix flaky color test 2023-05-13 21:39:11 +02:00
Erik Kundt 4142d85178
tui: Implement page stack and page state 2023-05-12 14:35:03 +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 87ae8cfb62
cob: Fix some clippy warnings 2023-05-12 12:47:41 +02:00
Alexis Sellier f9c722c160
term: Add text wrapping to `TextArea` 2023-05-12 12:43:52 +02:00
Alexis Sellier 103ee4e23d
cli: Show commit listing in `rad patch show` 2023-05-12 12:43:44 +02:00
Adam Szkoda 4caafa9ce2
ci: Preserve generated TLS certs between restarts
To avoid hitting rate limits with letsencrypt.
2023-05-12 12:40:05 +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 ff9903bf96
cli-test: Various improvements
* Add `stderr` decorator to assert stderr output of commands instead of
  stdout.
* Add ability to set env vars on a per-test-block basis.
* Add `fail` decorator when a failure code is expected.
* Look for binaries in cargo target dir first.
2023-05-12 11:09:21 +02:00
Alexis Sellier 1dfaab6b4d
scripts: Use `seed` user instead of `root` 2023-05-12 11:08:59 +02:00
Alexis Sellier eef813fd46
node: Small simplification in wire protocol 2023-05-12 11:08:29 +02:00
Alexis Sellier 7037b52474
node: Read with timeout from worker channel
This change ensures that if we're waiting on a Git request packetline
that never arrives, we time out.
2023-05-11 14:52:55 +02:00
Alexis Sellier d758c4f203
node: Move seeds log to better place
Instead of logging connected/disconnected seeds every time the seeds function
is called, we only log it when a user calls the function.
2023-05-11 10:36:30 +02:00
Erik Kundt a5d85a0d24
tui: Use default colors in theme 2023-05-10 17:20:13 +02:00
xphoniex 35ce6663c1
node: Add `--alias` option to node
Signed-off-by: xphoniex <dj.2dixx@gmail.com>
2023-05-10 17:03:42 +02:00
Alexis Sellier 8da6363cb3
term: Remove `concolor` dependency
Use `anstyle-query` and `is-terminal` instead, which are the replacement
crates that are also used in `snapbox`.
2023-05-10 15:56:39 +02:00
Alexis Sellier d249937a61
Update dependencies
* radicle-surf
* radicle-git-ext
* amplify
2023-05-10 15:56:21 +02:00
Alexis Sellier c1d4e87d25
ci: Use local deploy script instead of CI
Further reduce GitHub reliance.
2023-05-10 10:41:01 +02:00
Vincenzo Palazzo b29321dbf7
cob: Fix recursion bug in TryFrom of Reference
This commit addresses the issue of recursion in the TryFrom
call of Reference by resolving the parent in a lazy way.

Due to constraints posed by the need to access `git2::Repository`
or `git2::Commit` to resolve the parent, this commit decides to
pull out the parent resolution logic from the `cob::object::Commit`
module and move it inside the `cob::store::Store` implementation by adding
a new method `parents_of`.

Suggested-by: Fintan Halpenny <fintan.halpenny@gmail.com>
Tested-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-05-09 10:11:36 +02:00
Alexis Sellier 1d9ee81b6d
node: Rename `reactor` module to `io`
The name was always confusing and didn't mean much in the contetx of the
service.
2023-05-08 19:31:20 +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
Alexis Sellier 293a76948f
Update `SignedRefs::save` function
* Remove redundant `remote` parameter
* Fix commit message and remove redundant remote
2023-05-08 11:13:55 +02: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
Alexis Sellier 0349699200
node: Don't connect to recently attempted peers 2023-05-05 17:23:52 +02:00
Alexis Sellier ca0abc4356
node: Keep track of connection attempts
When attempting to connect to a peer, and when succeeding, write the timestamp
to the database.

This will allow us to better select addresses and not retry peers to
soon.
2023-05-05 17:23:52 +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 c20421b0c6
node: Fix superfluous fetch error on macOS
On macOS, shutting down a socket returns an error if the socket is
already closed. We don't consider that a problem, as it just returns
`Ok(())` on Linux.
2023-05-03 17:20:32 +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
Alexis Sellier 1326774d4f
node: Add failing test for sigrefs fetch
Fetching sigrefs fails if the remote ref is an ancestor of the local ref.
2023-05-03 16:16:34 +02:00
Alexis Sellier 448ef67833
node: Add `Disconnect` command
This is useful especially in tests to disconnect two nodes. We also
expose `command` on the handle type (but not the trait).
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
Alexis Sellier 76eb7c08a1
scripts: Refuse to delete own remote
This can be unrecoverable.
2023-04-29 11:49:35 +02:00
Slack Coder b004fd8afb
rad-issue: Correct formatting 2023-04-28 16:08:44 +02:00
Fintan Halpenny 44a3a09e5c
radicle: check if ref exists when removing a cob
If the reference did not exist it is not necessary to create a new
`sigrefs` entry. Check that the reference exists before removing from
the cob store and only sign if it did.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-28 14:28:46 +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
Fintan Halpenny 3bfea69642
node: validate production in debug mode
Ensure that the production repository is validated after fetching and
performing deletions. This is to highlight any inconsistencies that
may show up between fetching and deleting references.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-28 14:26:47 +02:00
Fintan Halpenny 024218014b
node: test case for outdated refs
Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-28 14:26:47 +02:00
Fintan Halpenny 694bd345d9
node: use ls-remote when in fetching mode
Given the scenario of 3 peers, A, B, and C each having a project R. If
peer A has B's fork, but C does not, then when peer A attempts to
fetch from C the fetch will be rejected since Git will fail when a
refspec that is asked for does not exist on the remote side.

To avoid this, the fetch logic is changed so that the client first calls
ls-remote to the remote side, which results in the references that the
remote has which the client is interested in. The follow-up fetch then
uses these refs as the refspecs -- which should succeed unless there
was a race for a deletion on the remote side.

The rest of the verification logic stays the same, so the storage
should still be in a working state before transferring from the staged
repository to the production repository.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-04-28 14:26:47 +02:00