David Hendricks has uploaded this change for review.

View Change

git-hooks: Use check-style in pre-commit hook

This adds the check-style script to the pre-commit hook and makes
some minor changes to warnings printed by the script. Errors are
be non-fatal for now.

Change-Id: I58b9e64f825de0ca222277a7d16c3904368edfe6
Signed-off-by: David Hendricks <david.hendricks@gmail.com>
---
M util/git-hooks/pre-commit
M util/lint/check-style
2 files changed, 22 insertions(+), 13 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/95/44095/1
diff --git a/util/git-hooks/pre-commit b/util/git-hooks/pre-commit
index dbccb9e..db6b256 100755
--- a/util/git-hooks/pre-commit
+++ b/util/git-hooks/pre-commit
@@ -1,9 +1,22 @@
#!/bin/sh
+
#
-# A hook script to verify what is about to be committed.
-# Called by "git commit" with no arguments. The hook should
-# exit with non-zero status after issuing an appropriate message if
-# it wants to stop the commit.
+# This file is part of the flashrom project.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+set -e # -o errexit
+set -u # -o nounset

# Check for whitespace errors
-git diff-index --check --cached HEAD -- || exit 1
+git diff-index --check --cached HEAD --
+
+util/lint/check-style
diff --git a/util/lint/check-style b/util/lint/check-style
index 91ed197..06ced0b 100755
--- a/util/lint/check-style
+++ b/util/lint/check-style
@@ -89,6 +89,7 @@
printf "Warning: clang-format executable not found.\n"
printf "Set the correct path in $(canonicalize_filename "$0").\n"
printf "Skipping clang-format style check test.\n"
+ printf "Changes that violate style guidelines will not be accepted upstream.\n"
# exit 1
exit 0
fi
@@ -133,12 +134,7 @@
printf "and the clang-format rules:\n\n"
cat "$patch"

-printf "\nYou can apply these changes with:\n git apply $patch\n"
-printf "(may need to be called from the root directory of your repository)\n"
-
-# FIXME: clang-format is currently unusable, so don't abort the commit.
-# printf "Aborting commit. Apply changes and commit again or skip checking with"
-# printf " --no-verify (not recommended).\n"
-# exit 1
-
+printf "\nApply these changes using:\n"
+printf " git apply $patch\n"
+printf "Changes that violate style guidelines will not be accepted upstream.\n"
exit 0

To view, visit change 44095. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I58b9e64f825de0ca222277a7d16c3904368edfe6
Gerrit-Change-Number: 44095
Gerrit-PatchSet: 1
Gerrit-Owner: David Hendricks <david.hendricks@gmail.com>
Gerrit-MessageType: newchange