Skip to content

Commit 1cf05e6

Browse files
committed
[DAPS-DEPS] Update cpp-py-formatter to 0.3.1
1 parent ef25444 commit 1cf05e6

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/main.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,7 @@ impl App {
211211
Ok(())
212212
}
213213

214-
fn clone(&self, full_name: &str, r#ref: &str, depth: usize) -> Result<(), Box<dyn Error>> {
215-
let (ref_type, ref_name) = ref_to_branch(r#ref).ok_or("Invalid reference")?;
216-
214+
fn clone(&self, full_name: &str, branch: &str, depth: usize) -> Result<(), Box<dyn Error>> {
217215
assert!(cmd(
218216
"git",
219217
&[
@@ -232,14 +230,6 @@ impl App {
232230
.wait()?
233231
.success());
234232

235-
if ref_type == "tag" {
236-
// Checkout the commit associated with the tag
237-
assert!(cmd("git", &["checkout", ref_name])?.wait()?.success());
238-
} else {
239-
// Checkout the branch
240-
assert!(cmd("git", &["checkout", ref_name])?.wait()?.success());
241-
}
242-
243233
Ok(())
244234
}
245235

@@ -420,7 +410,7 @@ FLAGS:
420410

421411
fn check(&self, _matches: &ArgMatches) -> Result<(), Box<dyn Error>> {
422412
let payload: GitHubPushEvent = load_payload()?;
423-
let branch = ref_to_branch(&payload.r#ref);
413+
let branch = ref_to_branch(&payload.r#ref).ok_or("Invalid reference")?;
424414
self.clone(&payload.repository.full_name, branch, 1)?;
425415
self.format_all();
426416

@@ -449,16 +439,16 @@ fn load_payload<T: DeserializeOwned>() -> Result<T, Box<dyn Error>> {
449439
Ok(serde_json::from_str(&github_event)?)
450440
}
451441

452-
fn ref_to_branch(r#ref: &str) -> Option<(&str, &str)> {
442+
fn ref_to_branch(r#ref: &str) -> &str{
453443
let branch_prefix = "refs/heads/";
454444
let tag_prefix = "refs/tags/";
455445

456446
if r#ref.starts_with(branch_prefix) {
457-
Some(("branch", &r#ref[branch_prefix.len()..]))
447+
&r#ref[branch_prefix.len()..]
458448
} else if r#ref.starts_with(tag_prefix) {
459-
Some(("tag", &r#ref[tag_prefix.len()..]))
449+
&r#ref[tag_prefix.len()..]
460450
} else {
461-
None
451+
r#ref
462452
}
463453
}
464454

0 commit comments

Comments
 (0)