Check for merge commits with tidy

This commit is contained in:
Sadman Kazi 2017-04-12 00:57:34 -04:00
parent effdf7e995
commit e2c7e3d1e2

View file

@ -1053,9 +1053,12 @@ def run_lint_scripts(only_changed_files=False, progress=True, stylo=False):
def check_commits(path='.'):
"""Gets all commits since the last merge."""
args = ['git', 'log', '-n1', '--merges', '--format=%H']
last_merge = subprocess.check_output(args, cwd=path).strip()
args = ['git', 'log', '{}..HEAD'.format(last_merge), '--format=%s']
args = ['git', 'log', '-n1', '--merges', '--format=%H %an']
# last_merge stores both the commit hash and the author name
last_merge = subprocess.check_output(args, cwd=path).strip().split()
last_merge_hash = last_merge[0]
last_merge_author = last_merge[1]
args = ['git', 'log', '{}..HEAD'.format(last_merge_hash), '--format=%s']
commits = subprocess.check_output(args, cwd=path).lower().splitlines()
for commit in commits:
@ -1063,6 +1066,9 @@ def check_commits(path='.'):
if 'wip' in commit.split():
yield ('.', 0, 'no commits should contain WIP')
if last_merge_author != 'bors-servo':
yield ('.', 0, 'no merge commits allowed by authors other than bors-servo')
raise StopIteration