summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2017-12-11 20:33:01 +0100
committerKatarina Behrens <Katarina.Behrens@cib.de>2018-06-01 10:06:21 +0200
commit5893b40f1c52fec95e6003ec6614c61e85c7bd98 (patch)
tree9128257420196146aa949255b940929849b597fb /solenv
parent8a1411905b7624e4980e0cc4ae4e19551a832ab4 (diff)
Add parameter to format-check any commit
Adds a parameter to check-last-commit, so we can check either HEAD~<n> or an actual git hash id. Still default to the last commit HEAD~0. Change-Id: Iadcbadddb31c2887c3e0395ceef34b7c006967e4
Diffstat (limited to 'solenv')
-rwxr-xr-xsolenv/clang-format/check-last-commit18
1 files changed, 17 insertions, 1 deletions
diff --git a/solenv/clang-format/check-last-commit b/solenv/clang-format/check-last-commit
index 2db666ab2aec..57939815bb0a 100755
--- a/solenv/clang-format/check-last-commit
+++ b/solenv/clang-format/check-last-commit
@@ -12,6 +12,9 @@ use warnings;
use lib "solenv/clang-format";
use ClangFormat;
+my $commit = 0;
+my $commit_id = 'HEAD';
+
sub check_style()
{
if ( ! -e ".git" )
@@ -25,12 +28,13 @@ sub check_style()
my @bad_names = ();
my $blacklist_names = ClangFormat::get_blacklist();
my $clang_format = ClangFormat::find();
+ my $parent = $commit + 1;
# Get a list of non-deleted changed files.
# Explicitly use the low-level 'git diff-tree' (rather than plain 'git
# diff') so we get the new, but not the old files for renames and/or
# copies.
- open (FILES, "git diff-tree -r --diff-filter=AM --name-only HEAD^ HEAD |") || die "Cannot run git diff.";
+ open (FILES, "git diff-tree -r --diff-filter=AM --name-only ${commit_id}~${parent} ${commit_id}~${commit} |") || die "Cannot run git diff.";
while (my $filename = <FILES>)
{
chomp $filename;
@@ -75,6 +79,18 @@ sub check_style()
}
}
+if (scalar(@ARGV) == 1)
+{
+ if (($ARGV[0] !~ /^[0-9]+$/) || (scalar($ARGV[0]) >= 8))
+ {
+ $commit_id = $ARGV[0];
+ }
+ else
+ {
+ $commit = $ARGV[0];
+ }
+}
+
check_style();
exit(0);