aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy/servo_tidy/tidy.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/tidy/servo_tidy/tidy.py')
-rw-r--r--python/tidy/servo_tidy/tidy.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py
index 36679cf9b1f..1468d00bf42 100644
--- a/python/tidy/servo_tidy/tidy.py
+++ b/python/tidy/servo_tidy/tidy.py
@@ -1052,16 +1052,29 @@ def run_lint_scripts(only_changed_files=False, progress=True, stylo=False):
def check_commits(path='.'):
+ """ Checks if the test is being run under Travis CI environment
+ This is necessary since, after travis clones the branch for a PR, it merges
+ the branch against master, creating a merge commit. Hence, as a workaround,
+ we have to check if the second last merge commit is done by the author of
+ the pull request.
+ """
+ is_travis = os.environ.get('TRAVIS') == 'true'
+ number_commits = '-n2' if is_travis else '-n1'
+
"""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', number_commits, '--merges', '--format=%H:%an']
+ # last_merge stores both the commit hash and the author name of the last merge in the output
+ last_merge_hash, last_merge_author = subprocess.check_output(args, cwd=path).strip().splitlines()[-1].split(':')
+ args = ['git', 'log', '{}..HEAD'.format(last_merge_hash), '--format=%s']
commits = subprocess.check_output(args, cwd=path).lower().splitlines()
for commit in commits:
# .split() to only match entire words
if 'wip' in commit.split():
- yield ('.', 0, 'no commits should contain WIP')
+ yield (':', ':', 'no commits should contain WIP')
+
+ if last_merge_author != 'bors-servo':
+ yield (':', ':', 'no merge commits allowed, please rebase your commits over the upstream master branch')
raise StopIteration