Skip to content

Commit

Permalink
newt: Don't stop upgrade when some repos are in dirty state
Browse files Browse the repository at this point in the history
Now if force flag is not set, only repos in dirty state will
not get upgraded. The rest of the repos will be upgraded.
  • Loading branch information
m-gorecki committed Mar 8, 2024
1 parent 679b6a8 commit ebdf8b7
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions newt/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (inst *Installer) installPrompt(vm deprepo.VersionMap, op installOp,
}

util.StatusMessage(util.VERBOSITY_DEFAULT,
"Making the following changes to the project:\n")
"Trying to make the following changes to the project:\n")

names := vm.SortedNames()
for _, name := range names {
Expand Down Expand Up @@ -554,10 +554,6 @@ func verifyNewtCompat(repos []*repo.Repo, vm deprepo.VersionMap) error {
func (inst *Installer) Upgrade(candidates []*repo.Repo, force bool,
ask bool) error {

if err := verifyRepoDirtyState(candidates, force); err != nil {
return err
}

vm, err := inst.calcVersionMap(candidates)
if err != nil {
return err
Expand Down Expand Up @@ -591,6 +587,22 @@ func (inst *Installer) Upgrade(candidates []*repo.Repo, force bool,
// Upgrade each repo in the version map.
for _, r := range repos {
destVer := vm[r.Name()]
dirtyState, err := r.DirtyState()
if err != nil {
return err
}

if dirtyState != "" {
if !force {
util.StatusMessage(util.VERBOSITY_DEFAULT,
"%s is in dirty state, it won't be upgraded\n",
r.Name())
continue
} else {
util.OneTimeWarning("forced update of repo in dirty state: %s", r.Name())
}
}

if err := r.Upgrade(destVer); err != nil {
return err
}
Expand Down

0 comments on commit ebdf8b7

Please sign in to comment.