style(commit-msg): clean format

This commit is contained in:
2020-07-12 14:51:04 +08:00
parent dc7bed5b2d
commit 90cc2d33f9

View File

@@ -55,27 +55,27 @@ const END: &str = "\x1B[0m";
fn print_usage() { fn print_usage() {
print_info(&format!(r#"Please follow the commit spec: print_info(&format!(r#"Please follow the commit spec:
Format: {}<type>{}(<scope>){}: <subject>{} Format: {b}<type>{e}(<scope>){b}: <subject>{e}
<scope> is optional <scope> is optional
feat: add hat wobble {b}feat{e}: add hat wobble
^--^ ^------------^ ^--^ ^------------^
| | | |
| +-> Summary in present tense. | +-> Summary in present tense.
| |
+-------> Type: chore, docs, feat, fix, refactor, style, or test. +-------> Type: chore, docs, feat, fix, refactor, style, or test.
feat : new feature for the user, not a new feature for build script {b}feat{e} : new feature for the user, not a new feature for build script
fix : bug fix for the user, not a fix to a build script {b}fix{e} : bug fix for the user, not a fix to a build script
docs : changes to the documentation {b}docs{e} : changes to the documentation
style : formatting, missing semi colons, etc; no production code change {b}style{e} : formatting, missing semi colons, etc; no production code change
refactor : refactoring production code, eg. renaming a variable {b}refactor{e} : refactoring production code, eg. renaming a variable
test : adding missing tests, refactoring tests; no production code change {b}test{e} : adding missing tests, refactoring tests; no production code change
chore : updating grunt tasks etc; no production code change {b}chore{e} : updating grunt tasks etc; no production code change
Reference: {}https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716{} Reference: {u}https://gist.github.com/joshbuchea/6f47e86d2510bce28f8e7f42ae84c716{e}
or mirror: {}https://hatter.ink/wiki/view_raw.action?__access_token=PUBLIC&id=42{} or mirror: {u}https://hatter.ink/wiki/view_raw.action?__access_token=PUBLIC&id=42{e}
"#, BOLD, END, BOLD, END, UNDER, END, UNDER, END)); "#, b = BOLD, e = END, u = UNDER));
} }
fn install_commit_msg(force: bool) { fn install_commit_msg(force: bool) {
@@ -112,6 +112,6 @@ fn install_commit_msg(force: bool) {
fn exit_with_error() -> ! { process::exit(1) } fn exit_with_error() -> ! { process::exit(1) }
fn exit_with_error_message(msg: &str) -> ! { print_error(msg); exit_with_error() } fn exit_with_error_message(msg: &str) -> ! { print_error(msg); exit_with_error() }
fn print_info(msg: &str) { println!("{}[INFO ]{} {}", BOLD, END, msg); } fn print_info(msg: &str) { println!("{b}[INFO ]{e} {m}", b = BOLD, e = END, m = msg); }
fn print_ok(msg: &str) { println!("{}{}[OK ]{} {}{}{}", GREEN, BOLD, END, GREEN, msg, END); } fn print_ok(msg: &str) { println!("{g}{b}[OK ]{e} {g}{m}{e}", g = GREEN, b = BOLD, e = END, m = msg); }
fn print_error(msg: &str) { println!("{}{}[ERROR]{} {}{}{}", RED, BOLD, END, RED, msg, END); } fn print_error(msg: &str) { println!("{r}{b}[ERROR]{e} {r}{m}{e}", r = RED, b = BOLD, e = END, m = msg); }