mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-21 02:20:43 +08:00
cli: add rad patch show
Show patch information with `rad patch show`. Signed-off-by: Slack Coder <slackcoder@server.ky>
This commit is contained in:
@@ -238,23 +238,8 @@ pub fn run(
|
||||
anyhow::bail!("a title must be given");
|
||||
}
|
||||
|
||||
let title_pretty = &term::format::dim(format!("╭─ {} ───────", title));
|
||||
|
||||
term::blank();
|
||||
term::print(title_pretty);
|
||||
term::blank();
|
||||
|
||||
if description.is_empty() {
|
||||
term::print(term::format::italic("No description provided."));
|
||||
} else {
|
||||
term::markdown(&description);
|
||||
}
|
||||
|
||||
term::blank();
|
||||
term::print(term::format::dim(format!(
|
||||
"╰{}",
|
||||
"─".repeat(term::text_width(title_pretty) - 1)
|
||||
)));
|
||||
term::patch::print_title_desc(title, &description);
|
||||
term::blank();
|
||||
|
||||
if !confirm("Create patch?", &options) {
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
use super::common::*;
|
||||
use super::*;
|
||||
|
||||
use crate::terminal as term;
|
||||
use radicle::cob::patch;
|
||||
use radicle::git;
|
||||
use radicle::prelude::*;
|
||||
use radicle::storage::git::Repository;
|
||||
|
||||
pub fn run(
|
||||
storage: &Repository,
|
||||
profile: &Profile,
|
||||
workdir: &git::raw::Repository,
|
||||
patch_id: &PatchId,
|
||||
) -> anyhow::Result<()> {
|
||||
let patches = patch::Patches::open(profile.public_key, storage)?;
|
||||
let Some(patch) = patches.get(patch_id)? else {
|
||||
anyhow::bail!("Patch `{}` not found", patch_id);
|
||||
};
|
||||
|
||||
term::blank();
|
||||
term::print(format!("patch {}", patch_id));
|
||||
term::blank();
|
||||
|
||||
term::patch::print_title_desc(patch.title(), patch.description().unwrap_or(""));
|
||||
term::blank();
|
||||
|
||||
let target_head = patch_merge_target_oid(patch.target(), storage)?;
|
||||
let base_oid = workdir.merge_base(target_head, **patch.head())?;
|
||||
let commits = patch_commits(workdir, &base_oid, patch.head())?;
|
||||
term::patch::list_commits(&commits)?;
|
||||
term::blank();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user