Commit Graph

53 Commits

Author SHA1 Message Date
cloudhead 3ad84420bd
cli: Implement `rad cob migrate`
Adds the new `migrate` sub-command to migrate the COB database.
Checks for version when opening the COBs database and suggests the
command on out of date version.

Also adds the 2nd migration to the COBs cache, which updates the patch
JSON schema.
2024-11-22 21:27:45 +01:00
cloudhead 6c8ee4330e
radicle: Implement migration callback mechanism
Add the ability to have native migrations and progress callback
functions in migration code for the COB cache.
2024-11-14 17:21:33 +01:00
Fintan Halpenny 0d402647cb
term: allow Editor to be reusable
The `Editor` is very useful for correctly opening a text editor and making changes
to some initial input. The current use of `Editor` is only for getting input for
commets.

However, it would also be useful for opening up a text editor on some other
existing files or text, for example, in the command `rad config edit`.

The `Editor` struct was changed to have two new options, `truncate` and
`cleanup`, to allow the user of the struct to dictate whether existing text is
truncated, and if the underlying file should be remove.

The original `new` method is now named `comment`, mimicing the existing
construction of a temporary `RAD_COMMENT` file.

The new version of `new` accepts any file for the `Editor` and will open it
without truncating or removing the file.

`Editor` is now used for the `rad config edit` command.
2024-11-11 11:27:33 +01:00
Sebastian Martinez cae66b6168
Update `radicle-git-ext` to 0.8.0 2024-08-20 16:35:04 +02:00
cloudhead ab6ca14c88
tools: Add optional revision to `rad-merge` 2024-08-20 16:23:32 +02:00
cloudhead 84e3ba1482
Validate project names properly in all places
We were only validating names when passed as a flag to `rad init
--name`.
2024-07-31 16:05:31 +02:00
cloudhead 40f4383bbc
term: Implement content-aware pager
This is a pager (like `less`) that takes an `Element`, and dynamically
re-renders the element when the terminal size changes. This ensures that
the content is always properly wrapped and rendered.
2024-05-03 14:31:05 +02:00
cloudhead 9cdf0aa1fd
Update radicle crates to 0.9.0 2024-03-26 11:56:27 +01:00
Fintan Halpenny 985b0af3f6
radicle: implement caching for issues and patches
Implement caching for the `Issue` and `Patch` COB. This is achieved by
having the `Transaction::initial` and `Transaction::commit` methods
take a cache which can update the newly created/updated object. The
`Store::remove` method also takes the cache for removing the object
from the cache, as well as the repository.

This meant that the `*Mut` types for the respective COBs are required
to carry a cache alongside the repository store. Identities will not
be cached, and so this is always set to `NoCache` -- which performs no
caching, and always succeeds.

To perform cache reading for issues and patches, the `cache::Issues`
and `cache::Patches` traits are introduced. They capture the minimal
amount of methods that are needed for the `rad issue` and `rad patch`
CLI commands.

The implementor for each of these traits is there respective `Cache`
types, which combines their backing repository store and the SQLite
database. They both provide convenience methods:
- `create` (and `draft` for patches)
- `get_mut`
- `remove`
which can be used instead of their repository store counterparts.

All uses of the repository stores (where needed) are replaced with
`Cache` types.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2024-02-23 16:03:21 +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
Fintan Halpenny 924a2624a4
git: update git2-0.18.1
Update to git2-0.18.1, which also requires updating radicle-git-ext
and radicle-surf.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-12-04 11:11:36 +00:00
cloudhead 9b7c48ab40
cli: Improve `rad diff`
* Properly show the user when a file was moved or copied.
* Don't require a radicle project in the current repo.
2023-11-09 13:04:40 +01:00
cloudhead a70664368e
radicle: Move some functions to `Home` type
Certain functions in `Profile` did not need to be in there and could be
moved in the more basic `Home` type.
2023-11-03 17:08:18 +01: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 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 bfc3c7164f
tools: Add `rad-merge` tool
It happened that a small bug in the remote helper caused a patch not to
merge correctly on push. Hence, I implemented a `rad-merge` tool for
these cases where we need to fix broken state.
2023-09-01 14:33:23 +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
Alexis Sellier f92308cf25
cli: Make key encryption optional
By leaving the passphrase prompt blank, users can create unencrypted
keys.
2023-07-20 10:40:15 +02:00
Alexis Sellier 4634913b66
radicle: Split out `SignRepository` trait
This new trait is used when only signing refs is needed, and not general
write access to a repository.

We also implement `ReadRepository` and `SignRepository` for
`DraftStore`.
2023-07-14 16:58:23 +02:00
Alexis Sellier 45ccbde226
Update `radicle-surf` and `git-ref-format` 2023-07-14 16:57:55 +02:00
Alexis Sellier eb701be033
node: Make node aliases required
This is a fairly substantial change, which adds a new configuration file
to the user's `$RAD_HOME` that includes node configuration, including
the alias, and also makes node aliases required.

When running `rad auth`, the user is now prompted for an alias, which
defaults to `$USER`.

When running `rad self`, the alias is now shown.

If the user runs radicle without a config file, the defaults are loaded,
and `$USER` is used as the alias.
2023-07-11 18:08:59 +02:00
Alexis Sellier d249937a61
Update dependencies
* radicle-surf
* radicle-git-ext
* amplify
2023-05-10 15:56:21 +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 b2f9ca61d5
tools: Add tool to set canonical refs
It's possible to delete these refs, or for old repos not to have them.
2023-04-17 22:10:20 +02:00
Alexis Sellier adbf6f5bf5
cli: Improve `patch` command
Cleanup and simplify output of patch command.
2023-03-08 20:23:49 +01:00
Alexis Sellier 0a93fa833e
cli: Simplify & improve CLI output
Improvements to the CLI output as well as converging towards
`termion` as a backend.

The crates we were using for prompting and spinners were based on
a terminal backend called `console`, which is not really used
anywhere else. There were also limitations in terms of the output
of these crates.

Therefore, we switched to the `inquire` crate for prompting, using
the `termion` backend, which is very standard.

Additionally, we simplify the terminal output to use symbols:

! for Warning
✓ for Success
✗ for Error

... Instead of a mix of words and symbols.

We also include a modified version of the `yansi` crate which plays
well with our table formatting functions by automatically truncating
and padding output in a unicode-aware way.
2023-02-27 17:10:52 +01:00
Alexis Sellier 950fae209d
Make `ReadStorage` more usable
Previously, we were not able to access a `ReadRepository` instance
through `ReadStorage`. With this change, we are able to.
2023-02-15 22:08:20 +01:00
Fintan Halpenny 3f48c2c516
Rust 1.67
Rust 1.67 was announced[0]. Update the necessary files for running
1.67 and fix the clippy suggestions for string interpolation.

[0]: https://blog.rust-lang.org/2023/01/26/Rust-1.67.0.html

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2023-02-04 19:30:29 +01:00
Alexis Sellier 30e9d6103c
Cleanup `clone` code
Remove a bunch of different instances of it.
2023-01-25 17:51:49 +01:00
Alexis Sellier 963ad3c3d7
Get `rad clone` working correctly 2023-01-25 11:35:20 +01:00
Alexis Sellier 1f06f5340f
Make `Id` to string conversion more explicit
Two types of conversion: `canonical`, which is just the base58 encoding,
and `urn` which is like canonical, but includes `rad:`.
2023-01-24 13:49:03 +01:00
Alexis Sellier d31968509d
Speed up node E2E tests
By allowing the node to run using a `MockSigner`, we speed up tests
significantly, since PBKDF2 doesn't need to run.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
2023-01-17 11:01:36 +01:00
Alexis Sellier f193d7d6cc
Improvements to keystore
* Use the correct passphrase type everywhere
* Allow conversion of secret key
* Extract logic for storing a key in keystore

Signed-off-by: Alexis Sellier <self@cloudhead.io>
2022-12-27 13:43:16 +01:00
Alexis Sellier f26674a5a9
Upgrade Rust to 1.66
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-15 20:55:26 +01:00
Alexis Sellier 7b8bb08b08
Consolidate `node::Handle` traits into one
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-12-09 10:52:18 +01:00
Alexis Sellier fd936becf1
Make `Profile::init` more flexible
Allow passing a custom home.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-22 10:44:30 +01:00
Alexis Sellier 32cd94dd23
Add `rad-init` command
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-07 22:01:49 +01:00
Alexis Sellier 45c7f3049b
Update to Rust 1.65
* Use new let-else syntax
* Fix new clippy lints

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-05 12:47:26 +01:00
Alexis Sellier dc79130988
Zeroize passphrases
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 16:52:29 +01:00
Alexis Sellier 41f53f3fae
Small improvements to signer/agent
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 13:29:20 +01:00
Alexis Sellier 577b632056
Use `Signer::try_sign` in interactive contexts
In interactive (user) contexts, use `try_sign` instead of `sign`.

We also revisit the `Profile` by adding a `signer` method that can
fail, eg. if we couldn't connect to ssh-agent.

Finally, we replace `UnsafeSigner` with `MemorySigner`, which makes
use of `ssh::Keystore`.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-03 13:06:00 +01:00
Alexis Sellier f5212405c5
ssh: simplify `radicle-ssh` crate implementation
Remove the internal buffer and simplify code around that.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-11-01 22:12:19 +01:00
Slack Coder c11f5b13bf rad-auth: create profile when not found
Be careful about when to attempt creating a profile.  Errors could
trigger creating a profile even when unrelated to it not existing.

Profile::load(..) is altered to distinguish between these cases.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-10-28 09:38:12 -05:00
Fintan Halpenny c0b0d29e19
radicle-crypto: split out from radicle
The crypto types are useful to use in other components that are
separate from the radicle crate, e.g. the incoming radicle-cobs
crate.

Separate out the types into a radicle-crypto crate. This crate defines
the usual PublicKey, SecretKey, and Signature types. It also provides
the ssh functionality, under the `ssh` feature. It is also necessary
to provide the `From` impl for `Component` here, which again is
guarded by the `git-ref-format` feature.

The `Arbitrary` implementation are moved. The arbitrary decision of
redefining `ByteArray` in both radicle-crypto and radicle was made.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
X-Clacks-Overhead: GNU Terry Pratchett
2022-10-27 20:40:39 +01:00
Alexis Sellier 94f7675c72
Move `sign_refs` to `WriteRepository` trait
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-19 14:41:12 +02:00
Fintan Halpenny df15b497ab
radicle: namespace peers
The previous iteration of the storage layout for projects organised
peer's subtrees by the `refs/remotes` category. This layout leads to
problems when linking a working copy to the storage project. The fetch
refspec would look something like:

  fetch = +refs/remotes/abc/heads/*:refs/remotes/rad/*

This works perfectly fine when running:

  git fetch rad

but will fail when one tries to specify:

  git fetch rad main

Instead, the command would need to be:

  git fetch remotes/abc/heads/main

This patch proposes to move the use of `refs/namespaces` for each
peer. The layout looks similar in that each peer has a subtree, but
instead it is under `refs/namespaces/<peer>/refs/...`.

The previous refspec would look more familiar in its new form:

  fetch = +refs/heads/*:refs/remotes/rad/*

With this in place running:

  git --namespace=abc rad main

Will work as expected and place the reference under
`refs/remotes/rad/main`. Similary, `git --namespace=abc push` will
work as expected.

Another benefit of this approach is that the use of namespacing means
that a tag is pushed it will be placed under the respective namespace
rather than in the global `refs/tags` category.

The actual implementation needed to work around the fact that
`git2`/`libgit2` does not have any options for fetching or pushing
using namespaces. The working copy code uses processes to shell out to
`git` for namespacing needs.

Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
2022-10-12 12:30:05 +02:00
Alexis Sellier 5b673c7440
Add `rad-clone` initial sketch
Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-03 11:50:43 +02:00
Alexis Sellier 2acd999c16
Add SSH functionality with new `radicle-ssh`
We borrow code from `thrussh`, refactored to be runtime-less.

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
2022-10-03 10:34:59 +02:00
Slack Coder f9ad3ac155 git: Use RefString types for git::refs
Lean on rust's type system to improve safety.

Signed-off-by: Slack Coder <slackcoder@server.ky>
2022-09-28 16:11:03 -05:00
Alexis Sellier 27e39c0df5
Make `Id` a `Copy` 2022-09-27 14:13:20 +02:00