Skip to content
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

fix(@angular/cli): provide an option to update dirty repositories #14596

Merged
merged 2 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/angular/cli/commands/update-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,19 @@ export class UpdateCommand extends SchematicCommand<UpdateCommandSchema> {

// If not asking for status then check for a clean git repository.
// This allows the user to easily reset any changes from the update.
if ((packages.length !== 0 || options.all) && !this.checkCleanGit()) {
this.logger.error(
'Repository is not clean. Please commit or stash any changes before updating.',
);
const statusCheck = packages.length === 0 && !options.all;
if (!statusCheck && !this.checkCleanGit()) {
if (options.allowDirty) {
this.logger.warn(
'Repository is not clean. Update changes will be mixed with pre-existing changes.',
);
} else {
this.logger.error(
'Repository is not clean. Please commit or stash any changes before updating.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this message also suggest
or run with --allowDirty to make edits to the current state

Copy link
Member Author

@clydin clydin May 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They should ideally commit or stash rather than ignore the dirty state to allow for easily reverting back to a known good state. Encouraging the other option prevents that.

);

return 2;
return 2;
}
}

const packageManager = getPackageManager(this.workspace.root);
Expand Down
4 changes: 4 additions & 0 deletions packages/angular/cli/commands/update.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
"to": {
"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.",
"type": "string"
},
"allowDirty": {
"description": "Whether to allow updating when the repository contains modified or untracked files.",
"type": "boolean"
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/schematics/update/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,14 @@ function _validateUpdatePackages(
|| peerErrors;
});

// tslint:disable:max-line-length
if (!force && peerErrors) {
throw new SchematicsException(tags.stripIndents
`Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and instead address these warnings later.`);
}
// tslint:enable:max-line-length
}


Expand Down