Radish alpha
r
rad:zwTxygwuz5LDGBq255RA2CbNGrz8
Radicle CI broker
Radicle
Git
feat: cibtool event add --base value is not rev-parsed
Merged liw opened 1 year ago

This allows a value of, say, HEAD, which is convenient.

Signed-off-by: Lars Wirzenius liw@liw.fi

2 files changed +10 -6 a0122d88 938f6274
modified ci-broker.md
@@ -910,12 +910,11 @@ given an installed cibtool
when I run cibtool --db x.db event list
then stdout is exactly ""

-
when I run bash radenv.sh cibtool --db x.db event add --repo testy --ref main --commit HEAD --base c0ffee --id-file id.txt
+
when I run bash radenv.sh cibtool --db x.db event add --repo testy --ref main --commit HEAD --base HEAD --id-file id.txt

when I run cibtool --db x.db event show --id-file id.txt
then stdout contains "rad:"
then stdout contains "main"
-
then stdout contains "c0ffee"

when I run cibtool --db x.db event remove --id-file id.txt

modified src/bin/cibtoolcmd/event.rs
@@ -81,10 +81,10 @@ pub struct AddEvent {
    #[clap(long)]
    commit: String,

-
    /// The base commit referred to by the event. Optional, but must
-
    /// be a SHA commit id.
+
    /// The base commit referred to by the event. The value is parsed
+
    /// the same way as `--commit` value.
    #[clap(long)]
-
    base: Option<Oid>,
+
    base: Option<String>,

    /// Write the event to this file, as JSON, instead of adding it to
    /// the queue.
@@ -168,7 +168,12 @@ impl Leaf for AddEvent {
            RefString::try_from(name.clone()).map_err(|e| CibToolError::RefString(name, e))?;

        let event = if let Some(base) = &self.base {
-
            CiEvent::branch_updated(nid, rid, &name, oid, *base)
+
            let base = if let Ok(base) = Oid::from_str(base) {
+
                base
+
            } else {
+
                self.lookup_commit(rid, base)?
+
            };
+
            CiEvent::branch_updated(nid, rid, &name, oid, base)
                .map_err(CibToolError::BranchCreted)?
        } else {
            CiEvent::branch_created(nid, rid, &name, oid).map_err(CibToolError::BranchCreted)?