Skip to content

Instantly share code, notes, and snippets.

@yosugi
Created October 4, 2015 06:06
Show Gist options
  • Select an option

  • Save yosugi/4ce856e9f9c4eba6d40c to your computer and use it in GitHub Desktop.

Select an option

Save yosugi/4ce856e9f9c4eba6d40c to your computer and use it in GitHub Desktop.
git-diff-test
#!/usr/bin/env perl
use strict;
use warnings;
sub checkPhp {
my ($file) = @_;
return if ($file !~ /\.php$/);
my $ret = `php -l $file 2> /dev/null`;
if ($? == 0) {
print 'lint OK ' . $file . "\n";
} else {
print 'lint NG ' . $file . "\n";
print STDERR $ret;
}
}
sub runPhpUnit {
my ($file) = @_;
return if ($file !~ /Test\.php$/);
my $ret = `phpunit $file 2> /dev/null`;
if ($? == 0) {
print 'test OK ' . $file . "\n";
} else {
print 'test NG ' . $file . "\n";
print STDERR $ret;
}
}
__END__
=head1 NAME
git-diff-test - run lint to changed files
=head1 SYNOPSIS
$ git diff-test [<commit>]
=head1 USAGE
git diff-test HEAD^^
git diff-test branch_name
git diff-test tag_name
git diff-test commit..commit
=head1 AUTHOR
yosugi
=head1 LICENSE
MIT License (http://opensource.org/licenses/mit-license.php)
=cut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment