Skip to content

Instantly share code, notes, and snippets.

@ncaq
Last active February 10, 2020 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ncaq/1500d0a31c2620da4b95192c3088430a to your computer and use it in GitHub Desktop.
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/)
#!/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