Skip to content

Commit 962d60b

Browse files
clydinalexeagle
authored andcommitted
fix(@angular/cli): provide an option to update dirty repositories
1 parent cf3e3af commit 962d60b

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

packages/angular/cli/commands/update-impl.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,19 @@ export class UpdateCommand extends SchematicCommand<UpdateCommandSchema> {
8383

8484
// If not asking for status then check for a clean git repository.
8585
// This allows the user to easily reset any changes from the update.
86-
if ((packages.length !== 0 || options.all) && !this.checkCleanGit()) {
87-
this.logger.error(
88-
'Repository is not clean. Please commit or stash any changes before updating.',
89-
);
86+
const statusCheck = packages.length === 0 && !options.all;
87+
if (!statusCheck && !this.checkCleanGit()) {
88+
if (options.allowDirty) {
89+
this.logger.warn(
90+
'Repository is not clean. Update changes will be mixed with pre-existing changes.',
91+
);
92+
} else {
93+
this.logger.error(
94+
'Repository is not clean. Please commit or stash any changes before updating.',
95+
);
9096

91-
return 2;
97+
return 2;
98+
}
9299
}
93100

94101
const packageManager = getPackageManager(this.workspace.root);

packages/angular/cli/commands/update.json

+4
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
"to": {
5454
"description": "Version up to which to apply migrations. Only available with a single package being updated, and only on migrations only. Requires from to be specified. Default to the installed version detected.",
5555
"type": "string"
56+
},
57+
"allowDirty": {
58+
"description": "Whether to allow updating when the repository contains modified or untracked files.",
59+
"type": "boolean"
5660
}
5761
}
5862
}

0 commit comments

Comments
 (0)