Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
add a test to repoduce an issue with patch merging
Open 12b-bdz-dev opened 4 months ago

This is to reproduce the issue discussed in https://radicle.zulipchat.com/#narrow/channel/369873-Support/topic/Merged.20patch.20still.20appears.20open.20and.20not.20merged/with/562986406

6 files changed +240 -0 352c29c2 34fa61ff
added crates/radicle-cli/examples/workflow-2/1-new-project.md
@@ -0,0 +1 @@
+
../rad-init.md

\ No newline at end of file
added crates/radicle-cli/examples/workflow-2/2-cloning.md
@@ -0,0 +1 @@
+
../rad-clone.md

\ No newline at end of file
added crates/radicle-cli/examples/workflow-2/3-delegate.md
@@ -0,0 +1,46 @@
+
Alice adds Bob as a delegate using their DID,
+
`did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk`, (keeping threshold to `1`).
+

+
```
+
$ rad id update --title "Add Bob" --description "Add Bob as a delegate" --delegate did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
✓ Identity revision 7be665f9fccba97abb21b2fa85a6fd3181c72858 created
+
╭────────────────────────────────────────────────────────────────────────╮
+
│ Title    Add Bob                                                       │
+
│ Revision 7be665f9fccba97abb21b2fa85a6fd3181c72858                      │
+
│ Blob     93d3009787e5d8a481dffc4dd248ea46af592466                      │
+
│ Author   did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi      │
+
│ State    accepted                                                      │
+
│ Quorum   yes                                                           │
+
│                                                                        │
+
│ Add Bob as a delegate                                                  │
+
├────────────────────────────────────────────────────────────────────────┤
+
│ ✓ did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi alice (you) │
+
╰────────────────────────────────────────────────────────────────────────╯
+

+
@@ -1,13 +1,14 @@
+
 {
+
   "payload": {
+
     "xyz.radicle.project": {
+
       "defaultBranch": "master",
+
       "description": "Radicle Heartwood Protocol & Stack",
+
       "name": "heartwood"
+
     }
+
   },
+
   "delegates": [
+
-    "did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi"
+
+    "did:key:z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi",
+
+    "did:key:z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk"
+
   ],
+
   "threshold": 1
+
 }
+
```
+

+
Identity document changes might not be automatically announced. So we have to manually do it
+
```
+
$ rad sync -a
+
✓ Synced with 1 seed(s)
+
```
+

+
Note that alice should not need to follow bob, and then create
+
a tracking branch in its working copy, using the `rad remote add`,
+
because by default its policy scope is `all`
added crates/radicle-cli/examples/workflow-2/4-patch-create.md
@@ -0,0 +1,61 @@
+
Here Alice will create a patch, to latter be merged by Bob who has been added as delegate
+

+
```
+
$ git checkout -b flux-capacitor-power
+
$ touch REQUIREMENTS
+
```
+

+
Here the instructions are added to the project's `REQUIREMENTS` for 1.21
+
gigawatts and committed with git.
+

+
```
+
$ git add REQUIREMENTS
+
$ git commit -v -m "Define power requirements"
+
[flux-capacitor-power 250d1e0] Define power requirements
+
 1 file changed, 0 insertions(+), 0 deletions(-)
+
 create mode 100644 heartwood/REQUIREMENTS
+
```
+

+
Once the code is ready, we open a patch with our changes.
+

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

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

+
```
+
$ rad patch
+
╭─────────────────────────────────────────────────────────────────────────────────────────╮
+
│ ●  ID       Title                      Author         Reviews  Head     +   -   Updated │
+
├─────────────────────────────────────────────────────────────────────────────────────────┤
+
│ ●  19ebdb3  Define power requirements  alice   (you)  - -      250d1e0  +0  -0  now     │
+
╰─────────────────────────────────────────────────────────────────────────────────────────╯
+
$ rad patch show 19ebdb3
+
╭────────────────────────────────────────────────────╮
+
│ Title     Define power requirements                │
+
│ Patch     19ebdb34e07740eeb6c12c6dcbc2a41ccca189aa │
+
│ Author    alice (you)                              │
+
│ Head      250d1e07fe567ea34c8d90be75b367cb97a151da │
+
│ Base      [..                                    ] │
+
│ Branches  flux-capacitor-power                     │
+
│ Commits   ahead 1, behind 0                        │
+
│ Status    open                                     │
+
│                                                    │
+
│ See details.                                       │
+
├────────────────────────────────────────────────────┤
+
│ 250d1e0 Define power requirements                  │
+
├────────────────────────────────────────────────────┤
+
│ ● Revision 19ebdb3 @ 250d1e0 by alice (you) now    │
+
╰────────────────────────────────────────────────────╯
+
```
+

+
We can also confirm that the patch branch is in storage:
+

+
```
+
$ git ls-remote rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi refs/heads/patches/*
+
250d1e07fe567ea34c8d90be75b367cb97a151da	refs/heads/patches/19ebdb34e07740eeb6c12c6dcbc2a41ccca189aa
+
```
added crates/radicle-cli/examples/workflow-2/5-patch-merge.md
@@ -0,0 +1,88 @@
+
Bob, who has just been added as a delegate will now merge the patch created by Alice
+

+
```
+
$ rad sync -f
+
Fetching rad:z42hL2jL4XNk6K8oHQaSWfMgCL7ji from the network, found 1 potential seed(s).
+
✓ Target met: 1 seed(s)
+
🌱 Fetched from z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
$ git branch -r
+
  alice@z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi/master
+
  rad/master
+
$ rad patch list --open
+
╭───────────────────────────────────────────────────────────────────────────────────────────────────╮
+
│ ●  ID       Title                      Author                   Reviews  Head     +   -   Updated │
+
├───────────────────────────────────────────────────────────────────────────────────────────────────┤
+
│ ●  19ebdb3  Define power requirements  alice   z6MknSL…StBU8Vi  - -      250d1e0  +0  -0  now     │
+
╰───────────────────────────────────────────────────────────────────────────────────────────────────╯
+
$ rad patch show 19ebdb3
+
╭───────────────────────────────────────────────────────────╮
+
│ Title    Define power requirements                        │
+
│ Patch    19ebdb34e07740eeb6c12c6dcbc2a41ccca189aa         │
+
│ Author   alice z6MknSL…StBU8Vi                            │
+
│ Head     250d1e07fe567ea34c8d90be75b367cb97a151da         │
+
│ Base     f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354         │
+
│ Commits  ahead 1, behind 0                                │
+
│ Status   open                                             │
+
│                                                           │
+
│ See details.                                              │
+
├───────────────────────────────────────────────────────────┤
+
│ 250d1e0 Define power requirements                         │
+
├───────────────────────────────────────────────────────────┤
+
│ ● Revision 19ebdb3 @ 250d1e0 by alice z6MknSL…StBU8Vi now │
+
╰───────────────────────────────────────────────────────────╯
+
```
+

+
```
+
$ rad patch checkout 19ebdb3
+
✓ Switched to branch patch/19ebdb3 at revision 19ebdb3
+
✓ Branch patch/19ebdb3 setup to track rad/patches/19ebdb34e07740eeb6c12c6dcbc2a41ccca189aa
+
```
+

+
bob accepts and merges the code.
+

+
```
+
$ rad patch review 19ebdb3 --revision 19ebdb3 --accept
+
✓ Patch 19ebdb3 accepted
+
✓ Synced with 1 seed(s)
+
$ git checkout master
+
Your branch is up to date with 'rad/master'.
+
$ git merge patch/19ebdb3
+
Updating f2de534..250d1e0
+
Fast-forward
+
 heartwood/REQUIREMENTS | 0
+
 1 file changed, 0 insertions(+), 0 deletions(-)
+
 create mode 100644 heartwood/REQUIREMENTS
+
```
+
``` (stderr)
+
$ git push rad master
+
✓ Patch 19ebdb34e07740eeb6c12c6dcbc2a41ccca189aa merged at revision 250d1e0
+
✓ Canonical reference refs/heads/master updated to target commit 250d1e07fe567ea34c8d90be75b367cb97a151da
+
✓ Synced with 1 seed(s)
+
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6Mkt67GdsW7715MEfRuP4pSZxJRJh6kj6Y48WRqVv4N1tRk
+
   f2de534..250d1e0  master -> master
+
```
+

+
The patch is now merged and closed :).
+

+
```
+
$ rad patch show 19ebdb3
+
╭───────────────────────────────────────────────────────────╮
+
│ Title    Define power requirements                        │
+
│ Patch    19ebdb34e07740eeb6c12c6dcbc2a41ccca189aa         │
+
│ Author   alice z6MknSL…StBU8Vi                            │
+
│ Head     250d1e07fe567ea34c8d90be75b367cb97a151da         │
+
│ Base     f2de534b5e81d7c6e2dcaf58c3dd91573c0a0354         │
+
│ Commits  ahead 1, behind 0                                │
+
│ Status   merged                                           │
+
│                                                           │
+
│ See details.                                              │
+
├───────────────────────────────────────────────────────────┤
+
│ 250d1e0 Define power requirements                         │
+
├───────────────────────────────────────────────────────────┤
+
│ ● Revision 19ebdb3 @ 250d1e0 by alice z6MknSL…StBU8Vi now │
+
╰───────────────────────────────────────────────────────────╯
+
```
+

+

+

+

modified crates/radicle-cli/tests/commands.rs
@@ -2817,3 +2817,46 @@ fn rad_workflow() {
    )
    .unwrap();
}
+

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

+
    environment.repository(&alice);
+

+
    environment.test("workflow-2/1-new-project", &alice).unwrap();
+

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

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

+
    environment.test("workflow-2/2-cloning", &bob).unwrap();
+

+
    test(
+
        "examples/workflow-2/3-delegate.md",
+
        environment.work(&alice).join("heartwood"),
+
        Some(&alice.home),
+
        [],
+
    )
+
    .unwrap();
+

+
    test(
+
        "examples/workflow-2/4-patch-create.md",
+
        environment.work(&alice).join("heartwood"),
+
        Some(&alice.home),
+
        [],
+
    )
+
    .unwrap();
+

+
    test(
+
        "examples/workflow-2/5-patch-merge.md",
+
        environment.work(&bob).join("heartwood"),
+
        Some(&bob.home),
+
        [],
+
    )
+
    .unwrap();
+

+
}