Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Write test for merge commits with patches
cloudhead committed 2 years ago
commit 9bc636ae6ede6d03a33ff18480b119b5339e9bb7
parent 38f326948f9214c18f2a76506aca432b5a1c10d9
2 files changed +67 -0
added radicle-cli/examples/rad-merge-no-ff.md
@@ -0,0 +1,42 @@
+
Let's test that merge commits are handled properly in the context of patches.
+
First, let's create a patch.
+
``` (stderr) RAD_SOCKET=/dev/null
+
$ git checkout -b feature/1 -q
+
$ git commit --allow-empty -q -m "First change"
+
$ git push rad HEAD:refs/patches
+
✓ Patch 143bb0c962561b09e86478a53ba346b5ff934335 opened
+
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
 * [new reference]   HEAD -> refs/patches
+
```
+

+
Then let's update the master branch so that merging the patch would create a merge commit.
+
```
+
$ git checkout master -q
+
$ git commit --amend --allow-empty -q -m "Concurrent change"
+
$ git rev-parse HEAD
+
f65977beef04fcc5cd5395feed7ff4c37cd90a2f
+
```
+

+
Now let's merge the patch, creating a merge commit. We can see that one of the
+
parents is the patch head.
+
```
+
$ git merge feature/1 -q --no-ff
+
$ git show --format=raw HEAD
+
commit 737a10cfa29111afeb0d43cf3545cee386b939ec
+
tree b4eecafa9be2f2006ce1b709d6857b07069b4608
+
parent f65977beef04fcc5cd5395feed7ff4c37cd90a2f
+
parent 20aa5dde6210796c3a2f04079b42316a31d02689
+
author radicle <radicle@localhost> 1671125284 +0000
+
committer radicle <radicle@localhost> 1671125284 +0000
+

+
    Merge branch 'feature/1'
+

+
```
+

+
Finally, we push master and expect the patch to be merged.
+
``` (stderr) RAD_SOCKET=/dev/null
+
$ git push rad master
+
✓ Patch 143bb0c962561b09e86478a53ba346b5ff934335 merged
+
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
+
   f2de534..737a10c  master -> master
+
```
modified radicle-cli/tests/commands.rs
@@ -1100,6 +1100,31 @@ fn rad_merge_after_update() {
}

#[test]
+
fn rad_merge_no_ff() {
+
    let mut environment = Environment::new();
+
    let alice = environment.node(Config::test(Alias::new("alice")));
+
    let working = environment.tmp().join("working");
+

+
    fixtures::repository(working.join("alice"));
+

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

+
    test(
+
        "examples/rad-merge-no-ff.md",
+
        working.join("alice"),
+
        Some(&alice.home),
+
        [],
+
    )
+
    .unwrap();
+
}
+

+
#[test]
fn rad_patch_pull_update() {
    logger::init(log::Level::Debug);