Last active
January 1, 2016 06:49
-
-
Save youcune/8107996 to your computer and use it in GitHub Desktop.
git commitしたときに全角チルダが含まれていたらコミットを拒否する。EUC/UTF-8対応。Windowsで見ると全角チルダが化けてしまうためチェックスクリプト化しました。.git/hooks/pre-commitに設置して使います。
This file contains hidden or 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 perl | |
# git commitしたときに全角チルダが含まれていたらコミットを拒否する | |
# \x8F\xA2\xB7 : EUC-JPで全角チルダ | |
# \xEF\xBD\x9E : UTF-8で全角チルダ | |
use strict; | |
use warnings; | |
our @files = `git diff-index --name-status HEAD | cut -c3-`; | |
foreach my $file (@files){ | |
chomp($file); | |
open(IN, $file); | |
my $i = 1; | |
while(<IN>){ | |
die "[Rejected] $file contains illegal character(s) at line $i\n" if /\x8F\xA2\xB7|\xEF\xBD\x9E/; | |
$i ++; | |
} | |
close(IN); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment