angular-cli: Repository is not clean after cli/core update

🐞 Bug report

Command (mark with an x)

- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [x] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Is this a regression?

No, this issue only applies to updating from version 7 to 8.

Description

I’m unable to update @angular/material when following the update instructions for a basic application. After updating the project with ng update @angular/cli @angular/core, I’m receiving an error when attempting to run ng update @angular/material.

🔬 Minimal Reproduction

  1. Create a new application with the CLI v7.3.9 ng new update-test --routing --style scss
  2. cd into the app’s root directory and add angular material ng add @angular/material
  3. Select the Indigo/Pink theme, yes to HammerJS and browser animations
  4. Begin the update process to v8 ng update @angular/cli @angular/core
  5. Update material ng update @angular/material

The error should appear after entering the command in step 5 and before the schematic executes.

🔥 Exception or Error




Repository is not clean.  Please commit or stash any changes before updating.

🌍 Your Environment




     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 8.0.0
Node: 12.3.1
OS: darwin x64
Angular: 8.0.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0
@angular-devkit/build-angular     0.800.0
@angular-devkit/build-optimizer   0.800.0
@angular-devkit/build-webpack     0.800.0
@angular-devkit/core              8.0.0
@angular-devkit/schematics        8.0.0
@angular/cdk                      7.3.7
@angular/material                 7.3.7
@ngtools/webpack                  8.0.0
@schematics/angular               8.0.0
@schematics/update                0.800.0
rxjs                              6.5.2
typescript                        3.4.5
webpack                           4.30.0

Anything else relevant?

I was able to reproduce on both Windows 10 and OS X.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 6
  • Comments: 19 (12 by maintainers)

Most upvoted comments

FYI, there is an allow-dirty flag to bypass the repo check.

ng update @angular/cli @angular/core --allow-dirty

This is expected and intentional. The git repository has uncommitted changes. If the changes aren’t committed before the update then there would be a risk that the update may fail (or succeed but leave the application in a broken state) and there may be no easy way to revert the bad changes introduced by the update.

@rodlourenco The next patch release will account for your use case and only consider files inside the Angular workspace.

I just updated to 8.1.1 from 7 and this message and stopping the update is a huge pain. Please make the need for --allow-dirty to go away. A simple message with y/n is good enough. Actually, the whole update process this time has been a train wreak of crashing updates. Not the place for that discussion here but it hasn’t been this bad since RC days.

I have not yet encountered a situation where I want to make a commit for each migration. I generally have to run ng update @angular/cli and then ng update @angular/material --allow-dirty and then possibly one more update. I don’t want to make separate commits per migration. I only want to commit after the migrations are done, the project is building, tests are passing, and any other manual fixes or adjustments need to be made.

Encouraging a behavior that is an opinion of correctness is fine, but forcing a behavior that people do not want to follow is … unfortunate. There are more than one “right” way to do most things.

FYI, there is an allow-dirty flag to bypass the repo check.

ng update @angular/cli @angular/core --allow-dirty

This doesn’t seem to exist anymore in 8.0.0, although it’s still in their documentation, ng update --help has no mention of it and I’ve tried --allow-dirty/--allowDirty. I unfortunately had to commit and then undo that commit.

Or instead of saying “Please commit or stash any changes before updating.”…which is untrue because I have nothing to commit or stash… display either how to actually resolve the issue (–allow-dirty) or where to go to find the correct information.

p.s. when using --allow-dirty, it suggested I need to use --force. When --allow-dirty is used, it correctly suggests how to resolve any blockers.

@dcolakchile it’s unclear what you mean. https://github.com/angular/angular-cli/issues/14600#issuecomment-497513709 details how this is intended.

It would be nice if there was an angular.json option to set your updates to always --allow-dirty as I have to use it many times per week at this point. However, so far requests for that feature have not been met with much interest.

It’s also in 8.0.1+. 8.0.3+ has the fix for more complex git repositories that contain the Angular project in a nested directory.