cli: Allow merging patch drafts

This commit is contained in:
cloudhead 2024-01-02 14:54:20 +01:00
parent 1bb400c278
commit 79c1fb309e
No known key found for this signature in database
3 changed files with 40 additions and 1 deletions

View File

@ -0,0 +1,19 @@
Let's start by creating a draft patch.
``` (stderr) RAD_SOCKET=/dev/null
$ git checkout -b feature/1 -q
$ git commit --allow-empty -q -m "First change"
$ git push -o patch.draft rad HEAD:refs/patches
✓ Patch cf29ac6b10141058be66b94a92a81c703b972751 drafted
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
* [new reference] HEAD -> refs/patches
```
``` (stderr) RAD_SOCKET=/dev/null
$ git checkout master -q
$ git merge feature/1
$ git push rad master
✓ Patch cf29ac6b10141058be66b94a92a81c703b972751 merged
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
f2de534..20aa5dd master -> master
```

View File

@ -666,6 +666,26 @@ fn rad_patch_via_push() {
.unwrap();
}
#[test]
fn rad_patch_merge_draft() {
let mut environment = Environment::new();
let profile = environment.profile(config::profile("alice"));
let working = tempfile::tempdir().unwrap();
let home = &profile.home;
// Setup a test repository.
fixtures::repository(working.path());
test("examples/rad-init.md", working.path(), Some(home), []).unwrap();
test(
"examples/rad-patch-merge-draft.md",
working.path(),
Some(home),
[],
)
.unwrap();
}
#[test]
#[cfg(not(target_os = "macos"))]
fn rad_review_by_hunk() {

View File

@ -540,7 +540,7 @@ fn patch_merge_all<G: Signer>(
// Skip patches that failed to load.
continue;
};
if !patch.is_open() {
if !patch.is_open() && !patch.is_draft() {
continue;
}
// Later revisions are more likely to be merged, so we build the list backwards.