from style.repo import GitRepo from style.verifiers import all_verifiers, all_regions from style.style import StdioUI, check_ignores import argparse parser = argparse.ArgumentParser( description="gem5 git style checker hook") parser.add_argument("--verbose", "-v", action="store_true", help="Produce verbose output") args = parser.parse_args() git = GitRepo() opts = {} repo_base = git.repo_base() ui = StdioUI() os.chdir(repo_base) failing_files = set() staged_mismatch = set() for status, fname in git.status(filter="MA", cached=True): if args.verbose: print("Checking {}...".format(fname)) if check_ignores(fname): continue if status == "M":
"base", "configs", "cpu", "cpu-kvm", "cpu-minor", "cpu-o3", "cpu-simple", "dev", "dev-arm", "dev-virtio", "ext", "fastmodel", "gpu-compute", "learning-gem5", "mem", "mem-cache", "mem-garnet", "mem-ruby", "misc", "python", "scons", "sim", "sim-se", "sim-power", "stats", "system", "system-alpha", "system-arm", "systemc", "tests", "util", "RFC", "WIP" ] tags = ''.join(commit_header.split(':')[0].split()).split(',') if (any(tag not in valid_tags for tag in tags)): invalid_tag = next((tag for tag in tags if tag not in valid_tags)) _printErrorQuit("Invalid Gem5 tag: " + invalid_tag) # Go to git directory os.chdir(GitRepo().repo_base()) # Get the commit message commit_message = open(sys.argv[1]).read() # The first line of a commit must contain at least one valid gem5 tag, and # a commit title commit_message_lines = commit_message.splitlines() commit_header = commit_message_lines[0] commit_header_match = \ re.search("^(\S[\w\-][,\s*[\w\-]+]*:.+\S$)", commit_header) if ((commit_header_match is None)): _printErrorQuit("Invalid commit header") _validateTags(commit_header) # Make sure commit title does not exceed threshold. This line is limited to
from style.repo import GitRepo from style.verifiers import all_verifiers, all_regions from style.style import StdioUI import argparse parser = argparse.ArgumentParser( description="gem5 git style checker hook") parser.add_argument("--verbose", "-v", action="store_true", help="Produce verbose output") args = parser.parse_args() git = GitRepo() opts = {} repo_base = git.repo_base() context = 8 ui = StdioUI() os.chdir(repo_base) failing_files = set() for status, fname in git.status(filter="MA", cached=True): if args.verbose: print "Checking %s..." % fname if status == "M": regions = git.staged_regions(fname, context=context) else:
from style.repo import GitRepo from style.verifiers import all_verifiers, all_regions from style.style import StdioUI, check_ignores import argparse parser = argparse.ArgumentParser( description="gem5 git style checker hook") parser.add_argument("--verbose", "-v", action="store_true", help="Produce verbose output") args = parser.parse_args() git = GitRepo() opts = {} repo_base = git.repo_base() ui = StdioUI() os.chdir(repo_base) failing_files = set() staged_mismatch = set() for status, fname in git.status(filter="MA", cached=True): if args.verbose: print "Checking %s..." % fname if check_ignores(fname): continue if status == "M":
from style.repo import GitRepo from style.verifiers import all_verifiers, all_regions from style.style import StdioUI, check_ignores import argparse parser = argparse.ArgumentParser(description="gem5 git style checker hook") parser.add_argument("--verbose", "-v", action="store_true", help="Produce verbose output") args = parser.parse_args() git = GitRepo() opts = {} repo_base = git.repo_base() ui = StdioUI() os.chdir(repo_base) failing_files = set() """ for status, fname in git.status(filter="MA", cached=True): if args.verbose: print "Checking %s..." % fname if check_ignores(fname): continue if status == "M": regions = git.staged_regions(fname)