Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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( },
None => { panic!("You must be somewhere on refs/heads, and you aren't") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment