remote-helper: Don't allow opening an empty patch
If the commit range is empty, return an error.
This commit is contained in:
parent
431a389944
commit
0319bbb903
|
|
@ -222,3 +222,15 @@ $ rad patch show b8ab1c9
|
||||||
│ ↑ updated to f24334f8cea7b7a5bcaf3bc6deb1408c9bf507ad (9304dbc) [ ... ] │
|
│ ↑ updated to f24334f8cea7b7a5bcaf3bc6deb1408c9bf507ad (9304dbc) [ ... ] │
|
||||||
╰──────────────────────────────────────────────────────────────────────────────╯
|
╰──────────────────────────────────────────────────────────────────────────────╯
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Empty patch
|
||||||
|
|
||||||
|
If we try to open a patch without making any changes to our base branch (`master`),
|
||||||
|
we should get an error:
|
||||||
|
|
||||||
|
``` (stderr) (fail)
|
||||||
|
$ git push rad master:refs/patches
|
||||||
|
To rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi
|
||||||
|
! [remote rejected] master -> refs/patches (patch commits are already included in the base branch)
|
||||||
|
error: failed to push some refs to 'rad://z42hL2jL4XNk6K8oHQaSWfMgCL7ji/z6MknSLrJoTcukLrE435hVNQT4JUhbvWLX4kUzqkEStBU8Vi'
|
||||||
|
```
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,9 @@ pub enum Error {
|
||||||
/// Patch not found in store.
|
/// Patch not found in store.
|
||||||
#[error("patch `{0}` not found")]
|
#[error("patch `{0}` not found")]
|
||||||
NotFound(patch::PatchId),
|
NotFound(patch::PatchId),
|
||||||
|
/// Patch is empty.
|
||||||
|
#[error("patch commits are already included in the base branch")]
|
||||||
|
EmptyPatch,
|
||||||
/// COB store error.
|
/// COB store error.
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
Cob(#[from] radicle::cob::store::Error),
|
Cob(#[from] radicle::cob::store::Error),
|
||||||
|
|
@ -259,6 +262,9 @@ fn patch_open<G: Signer>(
|
||||||
|
|
||||||
let (_, target) = stored.canonical_head()?;
|
let (_, target) = stored.canonical_head()?;
|
||||||
let base = stored.backend.merge_base(*target, commit.id())?;
|
let base = stored.backend.merge_base(*target, commit.id())?;
|
||||||
|
if base == commit.id() {
|
||||||
|
return Err(Error::EmptyPatch);
|
||||||
|
}
|
||||||
let (title, description) = cli::patch::get_create_message(
|
let (title, description) = cli::patch::get_create_message(
|
||||||
opts.message,
|
opts.message,
|
||||||
&stored.backend,
|
&stored.backend,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue