Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: test for merging with no previous fork
✗ CI failure Fabrice Bellamy committed 4 months ago
commit 34fa61ff581a39b3f1e84841519fb8b4387526d2
parent 5e3ade8b82336b5cf9c6965d0b6e931a894ae465
1 failed (1 total) View logs
2 files changed +127 -0
added crates/radicle-cli/examples/rad-patch-merged-no-fork.md
@@ -0,0 +1,87 @@
+
In some rare scenarios, a delegate will merge a patch without having first
+
pushed to their default branch.
+

+
Here we start off with Alice adding Bob as a delegate:
+

+
``` ~alice
+
$ rad id update --title "Add Bob" --description "Add Bob as a delegate" --delegate did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk -q
+
7be665f9fccba97abb21b2fa85a6fd3181c72858
+
```
+

+
Bob clones the repository so that he can start working on it with Alice:
+

+
``` ~bob
+
$ rad clone rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji
+
✓ Seeding policy updated for rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji with scope 'all'
+
Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from the network, found 1 potential seed(s).
+
✓ Target met: 1 seed(s)
+
✓ Creating checkout in ./heartwood..
+
✓ Remote alice@z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi added
+
✓ Remote-tracking branch alice@z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi/master created for z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
✓ Repository successfully cloned under [..]/heartwood/
+
╭────────────────────────────────────╮
+
│ heartwood                          │
+
│ Radicle Heartwood Protocol & Stack │
+
│ 0 issues · 0 patches               │
+
╰────────────────────────────────────╯
+
Run `cd ./heartwood` to go to the repository directory.
+
```
+

+
Alice then goes ahead and prepares a patch:
+

+
``` ~alice
+
$ git checkout -b flux-capacitor-power
+
$ touch REQUIREMENTS
+
$ git add REQUIREMENTS
+
$ git commit -v -m "Define power requirements"
+
[flux-capacitor-power 3e674d1] Define power requirements
+
 1 file changed, 0 insertions(+), 0 deletions(-)
+
 create mode 100644 REQUIREMENTS
+
```
+

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

+
Bob, as a delegate decides to review the patch and deems it worthy to merge, so
+
first he syncs the repository:
+

+
``` ~bob
+
$ rad sync -f
+
Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from the network, found 1 potential seed(s).
+
✓ Target met: 1 seed(s)
+
🌱 Fetched from z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
```
+

+
He then checks out the patch and merges the changes in:
+

+
``` ~bob
+
$ rad patch checkout df868fc
+
✓ Switched to branch patch/df868fc at revision df868fc
+
✓ Branch patch/df868fc setup to track rad/patches/df868fc7985fa7217aaef8423d73a077868c02b3
+
$ git checkout master
+
Your branch is up to date with 'rad/master'.
+
$ git merge patch/df868fc
+
Updating f2de534..3e674d1
+
Fast-forward
+
 REQUIREMENTS | 0
+
 1 file changed, 0 insertions(+), 0 deletions(-)
+
 create mode 100644 REQUIREMENTS
+
```
+

+
Now that the changes are merged, he can push and have the patch merged:
+

+
``` ~bob (stderr)
+
$ git push rad master
+
✓ Patch df868fc7985fa7217aaef8423d73a077868c02b3 merged
+
✓ Canonical reference refs/heads/master updated to target commit 3e674d1a1df90807e934f9ae5da2591dd6848a33
+
✓ Synced with 1 seed(s)
+
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
 * [new branch]      master -> master
+
```
+

+
Note that Bob was creating a new `master` branch in this case, and did not need
+
to create one before merging the patch.
modified crates/radicle-cli/tests/commands.rs
@@ -2619,6 +2619,46 @@ fn rad_patch_fetch_2() {
}

#[test]
+
fn rad_patch_merged_no_fork() {
+
    let mut environment = Environment::new();
+
    let alice = environment.node("alice");
+
    let bob = environment.node("bob");
+

+
    environment.repository(&alice);
+

+
    test(
+
        "examples/rad-init.md",
+
        environment.work(&alice),
+
        Some(&alice.home),
+
        [],
+
    )
+
    .unwrap();
+

+
    let alice = alice.spawn();
+
    let mut bob = bob.spawn();
+

+
    bob.connect(&alice).converge([&alice]);
+

+
    formula(
+
        &environment.tempdir(),
+
        "examples/rad-patch-merged-no-fork.md",
+
    )
+
    .unwrap()
+
    .home(
+
        "alice",
+
        environment.work(&alice),
+
        [("RAD_HOME", alice.home.path().display())],
+
    )
+
    .home(
+
        "bob",
+
        environment.work(&bob),
+
        [("RAD_HOME", bob.home.path().display())],
+
    )
+
    .run()
+
    .unwrap();
+
}
+

+
#[test]
fn git_push_and_fetch() {
    let mut environment = Environment::new();
    let alice = environment.node("alice");