Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!');
}