Last active
February 10, 2020 16:54
-
-
Save ncaq/1500d0a31c2620da4b95192c3088430a to your computer and use it in GitHub Desktop.
[Gitのコミットメッセージでめっちゃタイプミスをするのでそろそろタイプミスを検出するhooksを書きました - ncaq](https://www.ncaq.net/2020/02/10/20/37/26/)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env raku | |
my IO::Path $commit-editmsg-path = IO::Path.new(@*ARGS[0]); | |
my IO::Path $project-root-path; | |
if !$commit-editmsg-path.is-absolute { | |
$project-root-path = IO::Path.new((run 'git', 'rev-parse', '--show-toplevel', :out).out.slurp(:close).trim); | |
} | |
my Str $commit-msg = slurp($commit-editmsg-path.absolute($project-root-path)); | |
my Str @prefixs = [ | |
'Merge ', | |
'added: ', | |
'changed: ', | |
'cleaned: ', | |
'deleted: ', | |
'fixed: ', | |
'modified: ', | |
'renamed: ', | |
'updated: ', | |
]; | |
for @prefixs -> $prefix { | |
if $commit-msg.starts-with($prefix) { | |
exit 0 | |
} | |
} | |
die "commit-msg: $commit-msg is invalid."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment