diff --git a/dev-infra/build-worker.js b/dev-infra/build-worker.js index 31bbc5970e..18f635a8ef 100644 --- a/dev-infra/build-worker.js +++ b/dev-infra/build-worker.js @@ -172,7 +172,7 @@ var GitCommandError = /** @class */ (function (_super) { var GitClient = /** @class */ (function () { /** * @param githubToken The github token used for authentication, if provided. - * @param _config The configuration, containing the github specific configuration. + * @param config The configuration, containing the github specific configuration. * @param baseDir The full path to the root of the repository base. */ function GitClient(githubToken, config, baseDir) { @@ -294,10 +294,6 @@ var GitClient = /** @class */ (function () { GitClient.prototype.hasUncommittedChanges = function () { return this.runGraceful(['diff-index', '--quiet', 'HEAD']).status !== 0; }; - /** Whether the repo has any local changes. */ - GitClient.prototype.hasLocalChanges = function () { - return this.runGraceful(['diff-index', '--quiet', 'HEAD']).status !== 0; - }; /** Sanitizes a given message by omitting the provided Github token if present. */ GitClient.prototype.omitGithubTokenFromMessage = function (value) { // If no token has been defined (i.e. no token regex), we just return the diff --git a/dev-infra/ng-dev.js b/dev-infra/ng-dev.js index ce99daa2e4..21795f21bf 100755 --- a/dev-infra/ng-dev.js +++ b/dev-infra/ng-dev.js @@ -340,7 +340,7 @@ var GitCommandError = /** @class */ (function (_super) { var GitClient = /** @class */ (function () { /** * @param githubToken The github token used for authentication, if provided. - * @param _config The configuration, containing the github specific configuration. + * @param config The configuration, containing the github specific configuration. * @param baseDir The full path to the root of the repository base. */ function GitClient(githubToken, config, baseDir) { @@ -462,10 +462,6 @@ var GitClient = /** @class */ (function () { GitClient.prototype.hasUncommittedChanges = function () { return this.runGraceful(['diff-index', '--quiet', 'HEAD']).status !== 0; }; - /** Whether the repo has any local changes. */ - GitClient.prototype.hasLocalChanges = function () { - return this.runGraceful(['diff-index', '--quiet', 'HEAD']).status !== 0; - }; /** Sanitizes a given message by omitting the provided Github token if present. */ GitClient.prototype.omitGithubTokenFromMessage = function (value) { // If no token has been defined (i.e. no token regex), we just return the @@ -3110,7 +3106,7 @@ function checkOutPullRequestLocally(prNumber, githubToken, opts = {}) { const git = GitClient.getAuthenticatedInstance(); // In order to preserve local changes, checkouts cannot occur if local changes are present in the // git environment. Checked before retrieving the PR to fail fast. - if (git.hasLocalChanges()) { + if (git.hasUncommittedChanges()) { throw new UnexpectedLocalChangesError('Unable to checkout PR due to uncommitted changes.'); } /** @@ -3250,7 +3246,7 @@ function discoverNewConflictsForPr(newPrNumber, updatedAfter) { const git = GitClient.getAuthenticatedInstance(); // If there are any local changes in the current repository state, the // check cannot run as it needs to move between branches. - if (git.hasLocalChanges()) { + if (git.hasUncommittedChanges()) { error('Cannot run with local changes. Please make sure there are no local changes.'); process.exit(1); } @@ -4582,8 +4578,7 @@ function rebasePr(prNumber, githubToken, config = getConfig()) { return tslib.__awaiter(this, void 0, void 0, function* () { /** The singleton instance of the GitClient. */ const git = GitClient.getAuthenticatedInstance(); - // TODO: Rely on a common assertNoLocalChanges function. - if (git.hasLocalChanges()) { + if (git.hasUncommittedChanges()) { error('Cannot perform rebase of PR with local changes.'); process.exit(1); } diff --git a/dev-infra/pr/common/checkout-pr.ts b/dev-infra/pr/common/checkout-pr.ts index c6464b7a9f..57098d9f19 100644 --- a/dev-infra/pr/common/checkout-pr.ts +++ b/dev-infra/pr/common/checkout-pr.ts @@ -67,7 +67,7 @@ export async function checkOutPullRequestLocally( // In order to preserve local changes, checkouts cannot occur if local changes are present in the // git environment. Checked before retrieving the PR to fail fast. - if (git.hasLocalChanges()) { + if (git.hasUncommittedChanges()) { throw new UnexpectedLocalChangesError('Unable to checkout PR due to uncommitted changes.'); } diff --git a/dev-infra/pr/discover-new-conflicts/index.ts b/dev-infra/pr/discover-new-conflicts/index.ts index be2a2cc2fd..95ecd95960 100644 --- a/dev-infra/pr/discover-new-conflicts/index.ts +++ b/dev-infra/pr/discover-new-conflicts/index.ts @@ -57,7 +57,7 @@ export async function discoverNewConflictsForPr(newPrNumber: number, updatedAfte const git = GitClient.getAuthenticatedInstance(); // If there are any local changes in the current repository state, the // check cannot run as it needs to move between branches. - if (git.hasLocalChanges()) { + if (git.hasUncommittedChanges()) { error('Cannot run with local changes. Please make sure there are no local changes.'); process.exit(1); } diff --git a/dev-infra/pr/rebase/index.ts b/dev-infra/pr/rebase/index.ts index a892a7e452..f5889f992c 100644 --- a/dev-infra/pr/rebase/index.ts +++ b/dev-infra/pr/rebase/index.ts @@ -46,8 +46,7 @@ export async function rebasePr( prNumber: number, githubToken: string, config: Pick = getConfig()) { /** The singleton instance of the GitClient. */ const git = GitClient.getAuthenticatedInstance(); - // TODO: Rely on a common assertNoLocalChanges function. - if (git.hasLocalChanges()) { + if (git.hasUncommittedChanges()) { error('Cannot perform rebase of PR with local changes.'); process.exit(1); } diff --git a/dev-infra/utils/git/index.ts b/dev-infra/utils/git/index.ts index 9e7f9b8f83..c428da2c5f 100644 --- a/dev-infra/utils/git/index.ts +++ b/dev-infra/utils/git/index.ts @@ -115,7 +115,7 @@ export class GitClient { /** * @param githubToken The github token used for authentication, if provided. - * @param _config The configuration, containing the github specific configuration. + * @param config The configuration, containing the github specific configuration. * @param baseDir The full path to the root of the repository base. */ protected constructor(public githubToken: Authenticated extends true? string: undefined, @@ -214,11 +214,6 @@ export class GitClient { return this.runGraceful(['diff-index', '--quiet', 'HEAD']).status !== 0; } - /** Whether the repo has any local changes. */ - hasLocalChanges(): boolean { - return this.runGraceful(['diff-index', '--quiet', 'HEAD']).status !== 0; - } - /** Sanitizes a given message by omitting the provided Github token if present. */ omitGithubTokenFromMessage(value: string): string { // If no token has been defined (i.e. no token regex), we just return the