diff --git a/src/commands/commit.rs b/src/commands/commit.rs index 02a8686..cf04fe7 100644 --- a/src/commands/commit.rs +++ b/src/commands/commit.rs @@ -3,7 +3,8 @@ use crate::models::{commit, index}; use super::status; -fn no_change() -> bool { //todo: move to status.rs +fn no_change() -> bool { + //todo: move to status.rs let change = status::changes_to_be_committed(); change.new.len() == 0 && change.modified.len() == 0 && change.deleted.len() == 0 } @@ -21,16 +22,18 @@ pub fn commit(message: String, allow_empty: bool) { let commit_hash = commit.save(); head::update_head_commit(&commit_hash); - { - let commit_target = { - match current_head { - head::Head::Branch(branch_name) => branch_name, - head::Head::Detached(commit_hash) => commit_hash[..6].to_string(), - } - }; - println!("commit to [{:?}] message{:?}", commit_target, message); - println!("commit hash: {:?}", commit_hash); + match current_head { + head::Head::Branch(branch_name) => { + println!("commit to [{:?}] message{:?}", branch_name, message) + } + head::Head::Detached(commit_hash) => println!( + "Detached HEAD commit {:?} message{:?}", + commit_hash[0..7].to_string(), + message + ), } + + println!("commit hash: {:?}", commit_hash); } #[cfg(test)]