mod common;
use common::Repo;
#[test]
fn warns_the_first_time_an_identity_commits() {
let r = Repo::new();
r.git(&["config", "user.name", "test all mighty"]);
r.git(&["config", "user.email", "test@domain.test"]);
r.stage("a.txt", "x\n");
r.commit("feat: a");
r.git(&["config", "user.name", "test mighty"]);
assert!(r.hook("pre-commit-usual-name", &[]).says("first time"));
}
#[test]
fn stays_quiet_for_an_identity_already_in_the_log() {
let r = Repo::new();
r.git(&["config", "user.name", "test all mighty"]);
r.git(&["config", "user.email", "test@domain.test"]);
r.stage("a.txt", "x\n");
r.commit("feat: a");
assert!(!r.hook("pre-commit-usual-name", &[]).says("first time"));
}
#[test]
fn a_name_with_regex_metacharacters_is_matched_literally() {
let r = Repo::new();
r.git(&["config", "user.name", "test dev all mighty"]);
r.git(&["config", "user.email", "t@x.test"]);
r.stage("a.txt", "x\n");
r.commit("feat: a");
r.git(&["config", "user.name", "test (dev) all mighty"]);
assert!(r.hook("pre-commit-usual-name", &[]).says("first time"));
}
#[test]
fn never_blocks_a_commit() {
let r = Repo::new();
r.stage("a.txt", "x\n");
r.commit("feat: a");
r.git(&["config", "user.name", "someone new"]);
assert!(r.hook("pre-commit-usual-name", &[]).passed());
}