-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitcmp.py
More file actions
executable file
·57 lines (46 loc) · 2.33 KB
/
gitcmp.py
File metadata and controls
executable file
·57 lines (46 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
"""
Main entry point to git repository comparator.
"""
import argparse
from collections import OrderedDict
from checkers import references, commits, trees, blobs
from common import Common
from utils import load_repository, check_issues_and_exit
CHECKS = OrderedDict({'ref': references, 'commit': commits, 'tree': trees, 'blob': blobs})
def parse_arguments():
"""
Method used to setup argument parser and store parsed data.
"""
parser = argparse.ArgumentParser(description='Compare two Git repositories on selected level '
'with selected features.')
parser.add_argument('original', help='path to a repository checked against')
parser.add_argument('new', help='path to a checked repository')
parser.add_argument('--verbose', '-v', action='store_true', help='print detailed information')
parser.add_argument('--level', '-l', choices=CHECKS.keys(),
default='commit', help='level of comparison, default: commit')
parser.add_argument('--pedantic', '-p', action='store_true',
help='checked repository must not contain anything in excess')
parser.add_argument('--author', '-a', action='store_true',
help='check authorship details of commits as well (l>=commit)')
parser.add_argument('--references', '-r', metavar='refs', nargs='+',
help='check only selected references')
parser.add_argument('--reject-msg', metavar='regex',
help='reject commit when "regex" found in commit message')
parser.add_argument('--ignore-whitespace', choices=['leading', 'both'], default='none',
help='ignore leading whitespace in blobs')
parser.add_argument('--print-commit-titles', action='store_true',
help='enables printing commit titles in repository structure hints')
Common.compile_args(parser.parse_args())
if __name__ == "__main__":
parse_arguments()
# load repositories
Common.original = load_repository(Common.args.original)
Common.new = load_repository(Common.args.new)
check_issues_and_exit()
for name, checker in CHECKS.items():
checker.check()
check_issues_and_exit()
if name == Common.args.level:
break
print("Repositories match.")