angular-cli/scripts/validate.ts
Alan Agius ab84fc56b3 ci: remove validate-do-not-submit check
This uses  `git merge-base --fork-point master` which currently is not yielding a SHA on the patch branch. In some cases merge-base will not working as expected when base is ahead. See https://public-inbox.org/git/xmqq375okvxy.fsf@gitster.mtv.corp.google.com/T/#r3830f032d76f39b82d0ffe7f8bd77351cf634d29

This validation checks if `DO_NOT_SUBMIT` string literal has been added using `git diff`, when present validation will fail.

This check is unneeded as we do not use the `DO_NOT_SUBMIT` pattern, as we typically use `wip!` commit message types.
2021-02-03 12:18:26 -05:00

62 lines
1.8 KiB
TypeScript

/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
// tslint:disable:no-implicit-dependencies
import { logging, tags } from '@angular-devkit/core';
import { execSync } from 'child_process';
import templates from './templates';
import validateBuildFiles from './validate-build-files';
import validateLicenses from './validate-licenses';
import validateUserAnalytics from './validate-user-analytics';
export default async function (options: { verbose: boolean; ci: boolean }, logger: logging.Logger) {
let error = false;
if (execSync(`git status --porcelain`).toString()) {
logger.error('There are local changes.');
if (!options.verbose) {
return 101;
}
error = true;
}
logger.info('Running templates validation...');
const templateLogger = logger.createChild('templates');
await templates({}, templateLogger);
if (execSync(`git status --porcelain`).toString()) {
logger.error(tags.oneLine`
Running templates updated files... Please run "devkit-admin templates" before submitting
a PR.
`);
if (!options.verbose) {
process.exit(2);
}
error = true;
}
logger.info('');
logger.info('Running license validation...');
error = await validateLicenses({}, logger.createChild('validate-commits')) != 0
|| error;
logger.info('');
logger.info('Running BUILD files validation...');
error = await validateBuildFiles({}, logger.createChild('validate-build-files')) != 0
|| error;
logger.info('');
logger.info('Running User Analytics validation...');
error = await validateUserAnalytics({}, logger.createChild('validate-user-analytics')) != 0
|| error;
if (error) {
return 101;
}
return 0;
}