Skip to content

Commit 62eab67

Browse files
feat: allow omitted project in revision ref., default to try
1 parent 0704e2e commit 62eab67

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

src/main.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ struct Cli {
146146
#[clap(flatten)]
147147
options: Options,
148148
/// Refs. to the revision at the tip of TreeHerder push(es), of the form
149-
/// `<project>:<hash>`.
149+
/// `[<project>:]<hash>`.
150150
#[clap(value_parser = RevisionRef::from_str)]
151151
revisions: Vec<RevisionRef>,
152152
}
@@ -179,12 +179,21 @@ impl FromStr for RevisionRef {
179179
type Err = &'static str;
180180

181181
fn from_str(s: &str) -> Result<Self, Self::Err> {
182-
s.split_once(':')
183-
.map(|(project, hash)| Self {
184-
project: project.to_owned(),
185-
hash: hash.to_owned(),
186-
})
187-
.ok_or("no dividing colon found; expected revision ref. of the form <project>:<hash>")
182+
let project;
183+
let hash;
184+
185+
if let Some((p, h)) = s.split_once(':') {
186+
project = p;
187+
hash = h;
188+
} else {
189+
project = "try";
190+
hash = s;
191+
}
192+
193+
Ok(Self {
194+
project: project.to_owned(),
195+
hash: hash.to_owned(),
196+
})
188197
}
189198
}
190199

0 commit comments

Comments
 (0)