mirror of
https://seed.radicle.dev/rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5.git
synced 2026-11-16 08:10:40 +08:00
Allow `rad patch checkout` to specify a revision to checkout that may not be the patch's latest.
30 lines
802 B
Rust
30 lines
802 B
Rust
use radicle::cob::patch;
|
|
use radicle::git::Oid;
|
|
use radicle::prelude::*;
|
|
use radicle::storage::git::Repository;
|
|
|
|
use crate::git;
|
|
|
|
use super::*;
|
|
|
|
pub fn run(
|
|
revision_id: &git::Rev,
|
|
profile: &Profile,
|
|
repository: &Repository,
|
|
) -> anyhow::Result<()> {
|
|
let signer = &term::signer(profile)?;
|
|
let mut patches = patch::Patches::open(repository)?;
|
|
|
|
let revision_id = revision_id.resolve::<Oid>(&repository.backend)?;
|
|
let (patch_id, _, revision_id, _) = patches
|
|
.find_by_revision(&patch::RevisionId::from(revision_id))?
|
|
.ok_or_else(|| anyhow!("Patch revision `{revision_id}` not found"))?;
|
|
let Ok(mut patch) = patches.get_mut(&patch_id) else {
|
|
anyhow::bail!("Patch `{patch_id}` not found");
|
|
};
|
|
|
|
patch.redact(revision_id, signer)?;
|
|
|
|
Ok(())
|
|
}
|