Skip to content

Commit

Permalink
fix(hook): use pre-commit instead of prepare-commit-message hook
Browse files Browse the repository at this point in the history
Using pre-commit hook type allows users to use the --no-verify git commit flag
  • Loading branch information
oknozor committed Nov 30, 2021
1 parent 4372b57 commit 6fe1a27
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/git/hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::path::Path;

pub static PRE_PUSH_HOOK: &[u8] = include_bytes!("assets/pre-push");
pub static PREPARE_COMMIT_HOOK: &[u8] = include_bytes!("assets/prepare-commit-msg");
const PRE_COMMIT_HOOK_PATH: &str = ".git/hooks/prepare-commit-msg";
const PRE_COMMIT_HOOK_PATH: &str = ".git/hooks/pre-commit";
const PRE_PUSH_HOOK_PATH: &str = ".git/hooks/pre-push";

pub enum HookKind {
Expand Down Expand Up @@ -82,7 +82,7 @@ mod tests {

cog.install_hook(HookKind::PrepareCommit)?;

assert_that!(PathBuf::from(".git/hooks/prepare-commit-msg")).exists();
assert_that!(PathBuf::from(".git/hooks/pre-commit")).exists();
assert_that!(PathBuf::from(".git/hooks/pre-push")).does_not_exist();
Ok(())
}
Expand All @@ -100,7 +100,7 @@ mod tests {
cog.install_hook(HookKind::PrePush)?;

assert_that!(PathBuf::from(".git/hooks/pre-push")).exists();
assert_that!(PathBuf::from(".git/hooks/prepare-commit-msg")).does_not_exist();
assert_that!(PathBuf::from(".git/hooks/pre-commit")).does_not_exist();
Ok(())
}

Expand All @@ -117,7 +117,7 @@ mod tests {
cog.install_hook(HookKind::All)?;

assert_that!(PathBuf::from(".git/hooks/pre-push")).exists();
assert_that!(PathBuf::from(".git/hooks/prepare-commit-msg")).exists();
assert_that!(PathBuf::from(".git/hooks/pre-commit")).exists();
Ok(())
}

Expand Down

0 comments on commit 6fe1a27

Please sign in to comment.