git-pre-commit.py (11407:e6cc41b0a03c) | git-pre-commit.py (11465:256ddcabe5e6) |
---|---|
1#!/usr/bin/env python 2# 3# Copyright (c) 2016 ARM Limited 4# All rights reserved 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating --- 44 unchanged lines hidden (view full) --- 53 help="Produce verbose output") 54 55args = parser.parse_args() 56 57git = GitRepo() 58 59opts = {} 60repo_base = git.repo_base() | 1#!/usr/bin/env python 2# 3# Copyright (c) 2016 ARM Limited 4# All rights reserved 5# 6# The license below extends only to copyright in the software and shall 7# not be construed as granting a license to any other intellectual 8# property including but not limited to intellectual property relating --- 44 unchanged lines hidden (view full) --- 53 help="Produce verbose output") 54 55args = parser.parse_args() 56 57git = GitRepo() 58 59opts = {} 60repo_base = git.repo_base() |
61context = 8 | |
62ui = StdioUI() 63 64os.chdir(repo_base) 65failing_files = set() 66 67for status, fname in git.status(filter="MA", cached=True): 68 if args.verbose: 69 print "Checking %s..." % fname 70 if status == "M": | 61ui = StdioUI() 62 63os.chdir(repo_base) 64failing_files = set() 65 66for status, fname in git.status(filter="MA", cached=True): 67 if args.verbose: 68 print "Checking %s..." % fname 69 if status == "M": |
71 regions = git.staged_regions(fname, context=context) | 70 regions = git.staged_regions(fname) |
72 else: 73 regions = all_regions 74 75 verifiers = [ v(ui, opts, base=repo_base) for v in all_verifiers ] 76 for v in verifiers: 77 if v.check(fname, regions): 78 failing_files.add(fname) 79 80if failing_files: 81 print >> sys.stderr 82 print >> sys.stderr, "Style checker failed for the following files:" 83 for f in failing_files: 84 print >> sys.stderr, "\t%s" % f 85 print >> sys.stderr 86 print >> sys.stderr, \ 87 "Please run the style checker manually to fix the offending files.\n" \ 88 "To check your modifications, run: util/style.py -m" 89 sys.exit(1) | 71 else: 72 regions = all_regions 73 74 verifiers = [ v(ui, opts, base=repo_base) for v in all_verifiers ] 75 for v in verifiers: 76 if v.check(fname, regions): 77 failing_files.add(fname) 78 79if failing_files: 80 print >> sys.stderr 81 print >> sys.stderr, "Style checker failed for the following files:" 82 for f in failing_files: 83 print >> sys.stderr, "\t%s" % f 84 print >> sys.stderr 85 print >> sys.stderr, \ 86 "Please run the style checker manually to fix the offending files.\n" \ 87 "To check your modifications, run: util/style.py -m" 88 sys.exit(1) |