Skip to content

Commit 7fa7fa7

Browse files
devversionjelbourn
authored andcommitted
fix(ci): analyze commits should scan complete commit range.
Closes #216
1 parent fb6e580 commit 7fa7fa7

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ before_script:
6767
- "sh -e /etc/init.d/xvfb start"
6868
- mkdir -p $LOGS_DIR
6969
- npm run tslint
70-
- "node ./scripts/ci/analyze-commits.js"
70+
- "node ./scripts/ci/forbidden-identifiers.js"
7171

7272

7373
script:

scripts/ci/analyze-commits.js renamed to scripts/ci/forbidden-identifiers.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ var blocked_statements = [
1616
];
1717

1818
var blockedRegex = new RegExp('\\+.*(' + blocked_statements.join('|') + ').*$', 'mg');
19+
var commit_range = process.env.TRAVIS_COMMIT_RANGE || 'HEAD~1';
1920

20-
var diff = child_process.execSync('git diff --unified=0 HEAD~1 ./src ./e2e').toString();
21-
var isInvalid = blockedRegex.test(diff);
21+
var diff = child_process.execSync(`git diff --unified=0 ${commit_range} ./src ./e2e`).toString();
22+
23+
if (blockedRegex.test(diff)) {
2224

23-
if (isInvalid) {
2425
console.warn('Warning: You are using a statement in your commit, which is not allowed.\n' +
2526
'Blocked Statements are: ' + blocked_statements.join(', ') + '\n' +
2627
'Please remove them, and the CI will continue.');
28+
2729
process.exit(1);
30+
2831
} else {
2932
console.log('Info: The commits have been analyzed and are valid!');
3033
}

0 commit comments

Comments
 (0)