feat(dev-infra): prevent git push from being called in dryRun mode (#41387)
Update GitClient to prevent the `push` command from being run in dryMode. PR Close #41387
This commit is contained in:
@@ -11,6 +11,7 @@ import {spawnSync, SpawnSyncOptions, SpawnSyncReturns} from 'child_process';
|
||||
|
||||
import {getConfig, getRepoBaseDir, NgDevConfig} from '../config';
|
||||
import {debug, info, yellow} from '../console';
|
||||
import {DryRunError, isDryRun} from '../dry-run';
|
||||
import {GithubClient} from './github';
|
||||
import {getRepositoryGitUrl, GITHUB_TOKEN_GENERATE_URL, GITHUB_TOKEN_SETTINGS_URL} from './github-urls';
|
||||
|
||||
@@ -89,6 +90,14 @@ export class GitClient {
|
||||
* info failed commands.
|
||||
*/
|
||||
runGraceful(args: string[], options: SpawnSyncOptions = {}): SpawnSyncReturns<string> {
|
||||
/** The git command to be run. */
|
||||
const gitCommand = args[0];
|
||||
|
||||
if (isDryRun() && gitCommand === 'push') {
|
||||
debug(`"git push" is not able to be run in dryRun mode.`);
|
||||
throw new DryRunError();
|
||||
}
|
||||
|
||||
// To improve the debugging experience in case something fails, we print all executed Git
|
||||
// commands to better understand the git actions occuring. Depending on the command being
|
||||
// executed, this debugging information should be logged at different logging levels.
|
||||
|
||||
Reference in New Issue
Block a user