Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
cli: Write test for merge commits with patches
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Aug 16, 2023
1 parent 38f3269 commit 9bc636a
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
42 changes: 42 additions & 0 deletions radicle-cli/examples/rad-merge-no-ff.md
Original file line number Diff line number Diff line change
@@ -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
```
25 changes: 25 additions & 0 deletions radicle-cli/tests/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,31 @@ fn rad_merge_after_update() {
.unwrap();
}

#[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);
Expand Down

0 comments on commit 9bc636a

Please sign in to comment.