aboutsummaryrefslogtreecommitdiffstats
path: root/python/tidy
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-12-03 14:15:22 -0800
committerGitHub <noreply@github.com>2016-12-03 14:15:22 -0800
commitda15790e41b9404845bec9ae4dcdc127d23fa8ca (patch)
treeb0336888db6fe4f191ba8e6f4508ad6ec9410345 /python/tidy
parent8992b654102f83bb809fa230ea3a5b84c2758946 (diff)
parent42e675942c5579790db13ab564986825550b1f27 (diff)
downloadservo-da15790e41b9404845bec9ae4dcdc127d23fa8ca.tar.gz
servo-da15790e41b9404845bec9ae4dcdc127d23fa8ca.zip
Auto merge of #14450 - SijmenSchoon:master, r=Wafflespeanut
Implement tidy commit message test <!-- Please describe your changes on the following line: --> Makes tidy check commit messages since the latest merge, failing if one of them contains the string "WIP". I have written a test for my changes, although it is a bit hacky. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #14388. <!-- Either: --> - [x] These changes do not require tests because this would require playing with a new/existing git repo <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14450) <!-- Reviewable:end -->
Diffstat (limited to 'python/tidy')
-rw-r--r--python/tidy/servo_tidy/tidy.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/python/tidy/servo_tidy/tidy.py b/python/tidy/servo_tidy/tidy.py
index 18bfcb6713e..682100f6e01 100644
--- a/python/tidy/servo_tidy/tidy.py
+++ b/python/tidy/servo_tidy/tidy.py
@@ -942,6 +942,21 @@ def run_lint_scripts(only_changed_files=False, progress=True):
yield error
+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']
+ 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')
+
+ raise StopIteration
+
+
def scan(only_changed_files=False, progress=True):
# check config file for errors
config_errors = check_config_file(CONFIG_FILE_PATH)
@@ -957,8 +972,11 @@ def scan(only_changed_files=False, progress=True):
dep_license_errors = check_dep_license_errors(get_dep_toml_files(only_changed_files), progress)
# other lint checks
lint_errors = run_lint_scripts(only_changed_files, progress)
+ # check commits for WIP
+ commit_errors = check_commits()
# chain all the iterators
- errors = itertools.chain(config_errors, directory_errors, file_errors, dep_license_errors, lint_errors)
+ errors = itertools.chain(config_errors, directory_errors, file_errors, dep_license_errors, lint_errors,
+ commit_errors)
error = None
for error in errors: