cli: Vanity review.rs update
Absorb a nested `if .. else` block into the match statement.
This commit is contained in:
parent
fe00ed7ca7
commit
2a0643cf1c
|
|
@ -233,45 +233,44 @@ pub fn run(options: Options, ctx: impl term::Context) -> anyhow::Result<()> {
|
||||||
by_hunk,
|
by_hunk,
|
||||||
unified,
|
unified,
|
||||||
hunk,
|
hunk,
|
||||||
} => {
|
} if by_hunk => {
|
||||||
if by_hunk {
|
let mut opts = git::raw::DiffOptions::new();
|
||||||
let mut opts = git::raw::DiffOptions::new();
|
opts.patience(true)
|
||||||
opts.patience(true)
|
.minimal(true)
|
||||||
.minimal(true)
|
.context_lines(unified as u32);
|
||||||
.context_lines(unified as u32);
|
|
||||||
|
|
||||||
builder::ReviewBuilder::new(patch_id, *profile.id(), &repository)
|
builder::ReviewBuilder::new(patch_id, *profile.id(), &repository)
|
||||||
.hunk(hunk)
|
.hunk(hunk)
|
||||||
.verdict(verdict)
|
.verdict(verdict)
|
||||||
.run(revision, &mut opts)?;
|
.run(revision, &mut opts)?;
|
||||||
|
}
|
||||||
|
Operation::Review { verdict, .. } => {
|
||||||
|
let message = options.message.get(REVIEW_HELP_MSG)?;
|
||||||
|
let message = message.replace(REVIEW_HELP_MSG.trim(), "");
|
||||||
|
let message = if message.is_empty() {
|
||||||
|
None
|
||||||
} else {
|
} else {
|
||||||
let message = options.message.get(REVIEW_HELP_MSG)?;
|
Some(message)
|
||||||
let message = message.replace(REVIEW_HELP_MSG.trim(), "");
|
};
|
||||||
let message = if message.is_empty() {
|
patch.review(*revision_id, verdict, message, &signer)?;
|
||||||
None
|
|
||||||
} else {
|
|
||||||
Some(message)
|
|
||||||
};
|
|
||||||
patch.review(*revision_id, verdict, message, &signer)?;
|
|
||||||
|
|
||||||
match verdict {
|
match verdict {
|
||||||
Some(Verdict::Accept) => {
|
Some(Verdict::Accept) => {
|
||||||
term::success!(
|
term::success!(
|
||||||
"Patch {} {}",
|
"Patch {} {}",
|
||||||
patch_id_pretty,
|
patch_id_pretty,
|
||||||
term::format::highlight("accepted")
|
term::format::highlight("accepted")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Some(Verdict::Reject) => {
|
Some(Verdict::Reject) => {
|
||||||
term::success!(
|
term::success!(
|
||||||
"Patch {} {}",
|
"Patch {} {}",
|
||||||
patch_id_pretty,
|
patch_id_pretty,
|
||||||
term::format::negative("rejected")
|
term::format::negative("rejected")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
term::success!("Patch {} reviewed", patch_id_pretty);
|
term::success!("Patch {} reviewed", patch_id_pretty);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue