Skip to content

Commit 7af827e

Browse files
authored
Merge pull request #5 from JoshuaSBrown/chore/DAPS-Release/address-tag-bug
[DAPS-DEPS] Update cpp-py-formatter to 0.3.1
2 parents ef25444 + cb5fbf1 commit 7af827e

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cpp-py-format"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
authors = ["Andrew Gaspar <[email protected]>","Joshua Brown <[email protected]>"]
55
edition = "2024"
66

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)