From 95b9de187156576302bb304664fbd6069017d267 Mon Sep 17 00:00:00 2001 From: Ashley Pittman Date: Wed, 2 Mar 2016 12:24:12 +0000 Subject: [PATCH] LU-7835 checkpatch: Update gerrit_checkpatch for new features. Allow checking of a single patch per invocation rather than running as daemon. Update wiki URL for coding standards. Supply --notree option allowing upstream checkpatch.pl to be used. Add linebreaks to output when reporting multiple errors per line of source Signed-off-by: Ashley Pittman Change-Id: I3823db55073b606fb84b84f520e598e8427b22e7 Signed-off-by: Ashley Pittman Reviewed-on: http://review.whamcloud.com/18748 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond --- contrib/scripts/gerrit_checkpatch.py | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/contrib/scripts/gerrit_checkpatch.py b/contrib/scripts/gerrit_checkpatch.py index 64c3e0d..cd77982 100755 --- a/contrib/scripts/gerrit_checkpatch.py +++ b/contrib/scripts/gerrit_checkpatch.py @@ -57,6 +57,7 @@ GERRIT_HOST = os.getenv('GERRIT_HOST', 'review.whamcloud.com') GERRIT_PROJECT = os.getenv('GERRIT_PROJECT', 'fs/lustre-release') GERRIT_BRANCH = os.getenv('GERRIT_BRANCH', 'master') GERRIT_AUTH_PATH = os.getenv('GERRIT_AUTH_PATH', 'GERRIT_AUTH') +GERRIT_CHANGE_NUMBER = os.getenv('GERRIT_CHANGE_NUMBER', None) # GERRIT_AUTH should contain a single JSON dictionary of the form: # { @@ -70,6 +71,7 @@ GERRIT_AUTH_PATH = os.getenv('GERRIT_AUTH_PATH', 'GERRIT_AUTH') # } CHECKPATCH_PATHS = _getenv_list('CHECKPATCH_PATHS', ['checkpatch.pl']) +CHECKPATCH_ARGS = os.getenv('CHECKPATCH_ARGS','--show-types -').split(' ') CHECKPATCH_IGNORED_FILES = _getenv_list('CHECKPATCH_IGNORED_FILES', [ 'lustre/contrib/wireshark/packet-lustre.c', 'lustre/ptlrpc/wiretest.c', @@ -81,7 +83,7 @@ CHECKPATCH_IGNORED_KINDS = _getenv_list('CHECKPATCH_IGNORED_KINDS', [ 'LEADING_SPACE']) REVIEW_HISTORY_PATH = os.getenv('REVIEW_HISTORY_PATH', 'REVIEW_HISTORY') STYLE_LINK = os.getenv('STYLE_LINK', - 'https://wiki.hpdd.intel.com/display/PUB/Coding+Guidelines') + 'http://wiki.lustre.org/Lustre_Coding_Style_Guidelines') USE_CODE_REVIEW_SCORE = False @@ -105,7 +107,7 @@ def parse_checkpatch_output(out, path_line_comments, warning_count): path_comments = path_line_comments.setdefault(path, {}) line_comments = path_comments.setdefault(line, []) - line_comments.append('(style) ' + message) + line_comments.append('(style) %s\n' % message) warning_count[0] += 1 level = None # 'ERROR', 'WARNING' @@ -411,7 +413,7 @@ class Reviewer(object): warning_count = [0] for path in CHECKPATCH_PATHS: - pipe = subprocess.Popen([path, '--show-types', '-'], + pipe = subprocess.Popen([path] + CHECKPATCH_ARGS, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE) @@ -492,6 +494,18 @@ class Reviewer(object): self.timestamp = new_timestamp self.write_history('-', '-', 0) + def update_single_change(self, change): + + self.load_history() + + open_changes = self.get_changes({'status':'open', + 'change':change}) + self._debug("update: got %d open_changes", len(open_changes)) + + for change in open_changes: + if self.change_needs_review(change): + self.review_change(change) + def run(self): """ * Load review history. @@ -517,7 +531,11 @@ def main(): reviewer = Reviewer(GERRIT_HOST, GERRIT_PROJECT, GERRIT_BRANCH, username, password, REVIEW_HISTORY_PATH) - reviewer.run() + + if GERRIT_CHANGE_NUMBER: + reviewer.update_single_change(GERRIT_CHANGE_NUMBER) + else: + reviewer.run() if __name__ == "__main__": -- 1.8.3.1