Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
radicle-cli/tests: Add `rad_jj_patch`
Lorenz Leutgeb committed 7 months ago
commit 89e2a2b13958752a6a291970d75a3ce62a52d6b4
parent 79510f14592512682ad1be79e2049545e1f9a4d0
4 files changed +131 -0
added crates/radicle-cli/examples/jj-config.md
@@ -0,0 +1,19 @@
+
Let's make sure that the config is exactly what we expect.
+

+
```
+
$ jj config list
+
ui.editor = "true"
+
user.name = "Test User"
+
user.email = "test.user@example.com"
+
debug.commit-timestamp = "2001-02-03T04:05:06+07:00"
+
debug.randomness-seed = 0
+
debug.operation-timestamp = "2001-02-03T04:05:06+07:00"
+
operation.hostname = "host.example.com"
+
operation.username = "test-username"
+
```
+

+
We enable writing Change ID headers to our commits.
+

+
```
+
$ jj config set --user git.write-change-id-header true
+
```

\ No newline at end of file
added crates/radicle-cli/examples/jj-init-colocate.md
@@ -0,0 +1,10 @@
+
We initialize Jujutusu for our repository by colocating with Git.
+

+
```(stderr)
+
$ jj git init --colocate
+
Done importing changes from the underlying Git repo.
+
Hint: The following remote bookmarks aren't associated with the existing local bookmarks:
+
  master@rad
+
Hint: Run `jj bookmark track master@rad` to keep local bookmarks updated on future pulls.
+
Initialized repo in "."
+
```

\ No newline at end of file
added crates/radicle-cli/examples/rad-patch-jj.md
@@ -0,0 +1,91 @@
+
The scenario in this file is a variation of the one in `rad-patch.md`,
+
but uses Jujutsu.
+

+
```
+
$ touch REQUIREMENTS
+
$ jj describe --message "Define power requirements"
+
$ jj status
+
Working copy changes:
+
A REQUIREMENTS
+
Working copy  (@) : lvxkkpmk a6ea7b72 Define power requirements
+
Parent commit (@-): xpnzuzwn f2de534b master master@rad | Second commit
+
```
+

+
```
+
$ jj new
+
```
+

+
Just making sure that Git sees the Change ID…
+

+
```
+
$ git cat-file commit a6ea7b72
+
tree [..]
+
parent f2de534b[..]
+
author Test User <test.user@example.com> 981147906 +0700
+
committer Test User <test.user@example.com> 981147906 +0700
+
change-id lvxkkpmk[..]
+

+
Define power requirements
+
```
+

+
As of 2025-05 we can't use `jj` to do push with options directly, see:
+

+
 - <https://github.com/jj-vcs/jj/issues/4075>
+
 - <https://github.com/jj-vcs/jj/pull/2098>
+

+
However, since we initialized Jujutusu to colocate with Git, we can just use
+
Git to push.
+

+
``` (stderr)
+
$ git push rad -o patch.message="Define power requirements" -o patch.message="See details." HEAD:refs/patches
+
✓ Patch 1e31055ed3c41a48f2a71ba5317feb863b089700 opened
+
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
 * [new reference]   HEAD -> refs/patches
+
```
+

+
It will now be listed as one of the open patches.
+

+
```
+
$ rad patch
+
╭─────────────────────────────────────────────────────────────────────────────────────────╮
+
│ ●  ID       Title                      Author         Reviews  Head     +   -   Updated │
+
├─────────────────────────────────────────────────────────────────────────────────────────┤
+
│ ●  1e31055  Define power requirements  alice   (you)  -        a6ea7b7  +0  -0  now     │
+
╰─────────────────────────────────────────────────────────────────────────────────────────╯
+
```
+

+
Let's also create a bookmark for it.
+

+
```
+
$ jj bookmark create flux-capacitor-power
+
```
+

+
```
+
$ rad patch show 1e31055 -p
+
╭───────────────────────────────────────────────────╮
+
│ Title    Define power requirements                │
+
│ Patch    1e31055[..                             ] │
+
│ Author   alice (you)                              │
+
│ Head     a6ea7b7[..                             ] │
+
│ Base     f2de534[..                             ] │
+
│ Commits  ahead 1, behind 0                        │
+
│ Status   open                                     │
+
│                                                   │
+
│ See details.                                      │
+
├───────────────────────────────────────────────────┤
+
│ a6ea7b7 Define power requirements                 │
+
├───────────────────────────────────────────────────┤
+
│ ● Revision 1e31055 @ a6ea7b7 by alice (you) now   │
+
╰───────────────────────────────────────────────────╯
+

+
commit a6ea7b7[..]
+
Author: Test User <test.user@example.com>
+
Date:   Sat Feb 3 04:05:06 2001 +0700
+

+
    Define power requirements
+

+
diff --git a/REQUIREMENTS b/REQUIREMENTS
+
new file mode 100644
+
index 0000000..e69de29
+

+
```

\ No newline at end of file
modified crates/radicle-cli/tests/commands.rs
@@ -845,6 +845,17 @@ fn rad_patch() {
}

#[test]
+
fn rad_jj_colocated_patch() {
+
    // We test whether `jj` is installed, and have this test succeed if it is not.
+
    // Programmatic skipping of tests is not supported as of 2024-08.
+
    if !program_reports_version("jj") {
+
        return;
+
    }
+

+
    Environment::alice(["rad-init", "jj-config", "jj-init-colocate", "rad-patch-jj"])
+
}
+

+
#[test]
fn rad_patch_diff() {
    Environment::alice(["rad-init", "rad-patch-diff"]);
}