Created
November 7, 2014 17:59
-
-
Save adamhjk/2eb74d326242a9093f9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn current_branch(path: &Path) -> String { | |
let head_ref = head_ref(path); | |
println!("The ref for HEAD is {}", head_ref); | |
let r = regex!(r"refs/heads/(.+)"); | |
let caps_result = r.captures(head_ref.as_slice()); | |
let branch: String = match caps_result { | |
Some(cap) => { String::from_str(cap.at(1)) }, | |
None => { panic!("You must be somewhere on refs/heads, and you aren't") } | |
}; | |
branch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment