|
| 1 | +import sys |
| 2 | +import itertools |
| 3 | + |
| 4 | +from githammer import Hammer |
| 5 | + |
| 6 | + |
| 7 | +def check_commit(index, commit_old, commit_new, attr): |
| 8 | + old_attr = getattr(commit_old, attr) |
| 9 | + new_attr = getattr(commit_new, attr) |
| 10 | + if old_attr != new_attr: |
| 11 | + sys.exit('Error in commit {} ({}): Incorrect {} {} (expected {})'. |
| 12 | + format(index, commit_old.hexsha, attr, new_attr, old_attr)) |
| 13 | + |
| 14 | + |
| 15 | +if len(sys.argv) < 3: |
| 16 | + sys.exit('Usage: {} <known good project> <new project>'.format(sys.argv[0])) |
| 17 | + |
| 18 | +hammer_old = Hammer(sys.argv[1]) |
| 19 | +hammer_new = Hammer(sys.argv[2]) |
| 20 | + |
| 21 | +count = 0 |
| 22 | + |
| 23 | +for (index, (commit_old, commit_new)) in enumerate(itertools.zip_longest(hammer_old.iter_individual_commits(), |
| 24 | + hammer_new.iter_individual_commits())): |
| 25 | + check_commit(index, commit_old, commit_new, 'hexsha') |
| 26 | + check_commit(index, commit_old, commit_new, 'author_name') |
| 27 | + check_commit(index, commit_old, commit_new, 'added_lines') |
| 28 | + check_commit(index, commit_old, commit_new, 'deleted_lines') |
| 29 | + check_commit(index, commit_old, commit_new, 'commit_time') |
| 30 | + check_commit(index, commit_old, commit_new, 'commit_time_utc_offset') |
| 31 | + check_commit(index, commit_old, commit_new, 'line_counts') |
| 32 | + check_commit(index, commit_old, commit_new, 'test_counts') |
| 33 | + count += 1 |
| 34 | + |
| 35 | +print('OK, checked {} commits'.format(count)) |
0 commit comments