Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
git-remote-rad: Allow pushing commit SHAs into `refs/patches`
✓ CI success Tobias Hunger committed 10 months ago
commit a052e5d36cd0ecb4c6ec1bec6074748b7a05155f
parent 60d80abe8ef2d5bd9286fbc5d3dae8c101ab6572
1 passed (1 total) View logs
1 file changed +15 -2
modified crates/radicle-remote-helper/src/push.rs
@@ -390,6 +390,20 @@ pub fn run(
    Ok(())
}

+
fn commit_from_string<'repo>(
+
    working: &'repo git::raw::Repository,
+
    src: &'_ str,
+
) -> Result<git::raw::Commit<'repo>, Error> {
+
    if let Ok(oid) = git::raw::Oid::from_str(src) {
+
        if let Ok(object) = working.find_commit(oid) {
+
            return Ok(object);
+
        }
+
    }
+
    let reference = working.find_reference(src)?;
+
    let commit = reference.peel_to_commit()?;
+
    Ok(commit)
+
}
+

/// Open a new patch.
fn patch_open<G>(
    src: &git::RefStr,
@@ -408,8 +422,7 @@ fn patch_open<G>(
where
    G: crypto::signature::Signer<crypto::Signature>,
{
-
    let reference = working.find_reference(src.as_str())?;
-
    let commit = reference.peel_to_commit()?;
+
    let commit = commit_from_string(working, src.as_str())?;
    let dst = git::refs::storage::staging::patch(nid, commit.id());

    // Before creating the patch, we must push the associated git objects to storage.