diff options
-rw-r--r-- | src/bin/prepare-commit-msg.rs | 6 | ||||
-rw-r--r-- | src/lib.rs | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/bin/prepare-commit-msg.rs b/src/bin/prepare-commit-msg.rs index 63edba0..1a34fc2 100644 --- a/src/bin/prepare-commit-msg.rs +++ b/src/bin/prepare-commit-msg.rs @@ -9,10 +9,10 @@ use std::env; fn main() { log(); - - let current_branch = get_current_branch(); + let commit_filename = env::args().nth(1); - + + let current_branch = get_current_branch(); match (current_branch, commit_filename) { (Ok(branch), Some(filename)) => { @@ -5,7 +5,7 @@ use std::io::{stdin, BufRead}; use git2::Repository; - +// This consumes stdin. Do not call this if you need to use stdin. pub fn log() { let name_arg = env::args().nth(0).unwrap_or(String::from("unknown")); let args: Vec<_> = env::args().skip(1).collect(); @@ -19,6 +19,7 @@ pub fn log() { println!("END STDIN"); } +// Uses libgit to get the name of your current branch pub fn get_current_branch() -> Result<String, git2::Error> { let git_repo = Repository::discover("./")?; let head = git_repo.head()?; @@ -28,4 +29,3 @@ pub fn get_current_branch() -> Result<String, git2::Error> { None => Err(git2::Error::from_str("No branch name found")) } } - |