From ba3e054e7e7853c182a50f5c31a05bf6b19801a4 Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Fri, 4 May 2018 17:35:15 -0700 Subject: [PATCH] Allow clang-format in presubmit to be disabled By having 'disable-clang-format' in commit message. If you have the script setup as git pre-commit, it can be disabled by '--no-verify' option. Change-Id: I6fb358e85105255fddde41f950e986c74b7defc9 --- packager/tools/git/check_formatting.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packager/tools/git/check_formatting.py b/packager/tools/git/check_formatting.py index 429cc2aa73..bfd8d7cd8e 100755 --- a/packager/tools/git/check_formatting.py +++ b/packager/tools/git/check_formatting.py @@ -36,6 +36,12 @@ import subprocess import sys if __name__ == '__main__': + is_pre_commit_hook = len(sys.argv) == 1 + if not is_pre_commit_hook: + output = subprocess.check_output(['git', 'log', '--pretty=full', '-1']) + if 'disable-clang-format' in output: + sys.exit(0) + command = ['git', 'clang-format', '--style', 'Chromium'] command += sys.argv[1:] output = subprocess.check_output(command + ['--diff'])