fix(ci): analyze commits should scan complete commit range.

Closes #216
This commit is contained in:
DevVersion
2016-03-21 19:14:37 +01:00
committed by Jeremy Elbourn
parent fb6e580eab
commit 7fa7fa7bcc
2 changed files with 7 additions and 4 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ before_script:
- "sh -e /etc/init.d/xvfb start"
- mkdir -p $LOGS_DIR
- npm run tslint
- "node ./scripts/ci/analyze-commits.js"
- "node ./scripts/ci/forbidden-identifiers.js"
script:
@@ -16,15 +16,18 @@ var blocked_statements = [
];
var blockedRegex = new RegExp('\\+.*(' + blocked_statements.join('|') + ').*$', 'mg');
var commit_range = process.env.TRAVIS_COMMIT_RANGE || 'HEAD~1';
var diff = child_process.execSync('git diff --unified=0 HEAD~1 ./src ./e2e').toString();
var isInvalid = blockedRegex.test(diff);
var diff = child_process.execSync(`git diff --unified=0 ${commit_range} ./src ./e2e`).toString();
if (blockedRegex.test(diff)) {
if (isInvalid) {
console.warn('Warning: You are using a statement in your commit, which is not allowed.\n' +
'Blocked Statements are: ' + blocked_statements.join(', ') + '\n' +
'Please remove them, and the CI will continue.');
process.exit(1);
} else {
console.log('Info: The commits have been analyzed and are valid!');
}