Skip to content

Commit 5f32ab8

Browse files
committed
[TESTING] Fix dependency graph when no repos given
Fix dependency graph build when no repos were given to `upgrade`. FIXME: if this works must still add a `--no-deps` or such flag to enable compatibility with previous versions if deemed so... FIXME: squash later Signed-off-by: Fabio Utzig <[email protected]>
1 parent 944b1b5 commit 5f32ab8

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

newt/deprepo/deprepo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ func isInReqs(repo string, reqs RequirementMap) bool {
118118

119119
// Builds a repo dependency graph from the repo requirements expressed in the
120120
// `project.yml` file.
121-
func BuildDepGraph(repos RepoMap, rootReqs RequirementMap) (DepGraph, error) {
121+
func BuildDepGraph(repos RepoMap, rootReqs RequirementMap, noDeps bool) (DepGraph, error) {
122122
dg := DepGraph{}
123123

124124
// First, add the hard dependencies expressed in `project.yml`.
125125
for repoName, verReq := range rootReqs {
126126
repo, ok := repos[repoName]
127-
if !ok {
127+
if !ok && noDeps {
128128
continue
129129
}
130130
normalizedReq, err := repo.NormalizeVerReq(verReq)
@@ -140,14 +140,14 @@ func BuildDepGraph(repos RepoMap, rootReqs RequirementMap) (DepGraph, error) {
140140
// Add inter-repo dependencies to the graph.
141141
for _, r := range repos.Sorted() {
142142
nvers, err := r.NormalizedVersions()
143-
if err != nil && isInReqs(r.Name(), rootReqs) {
143+
if err != nil && noDeps && isInReqs(r.Name(), rootReqs) {
144144
return nil, err
145145
}
146146
for _, v := range nvers {
147147
deps := r.DepsForVersion(v)
148148
reqMap := RequirementMap{}
149149
for _, d := range deps {
150-
if !isInReqs(d.Name, rootReqs) {
150+
if noDeps && !isInReqs(d.Name, rootReqs) {
151151
continue
152152
}
153153
depRepo := repos[d.Name]

newt/install/install.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ func (inst *Installer) versionMapRepos(
416416

417417
// Calculates a map of repos and version numbers that should be included in an
418418
// install or upgrade operation.
419-
func (inst *Installer) calcVersionMap(candidates []*repo.Repo) (
419+
func (inst *Installer) calcVersionMap(candidates []*repo.Repo, noDeps bool) (
420420
deprepo.VersionMap, error) {
421421

422422
// Repos that depend on any specified repos must also be considered during
@@ -463,7 +463,7 @@ func (inst *Installer) calcVersionMap(candidates []*repo.Repo) (
463463

464464
// Construct a repo dependency graph from the `project.yml` version
465465
// requirements and from each repo's dependency list.
466-
dg, err := deprepo.BuildDepGraph(inst.repos, inst.reqs)
466+
dg, err := deprepo.BuildDepGraph(inst.repos, inst.reqs, noDeps)
467467
if err != nil {
468468
return nil, err
469469
}
@@ -550,13 +550,13 @@ func verifyNewtCompat(repos []*repo.Repo, vm deprepo.VersionMap) error {
550550

551551
// Installs or upgrades the specified set of repos.
552552
func (inst *Installer) Upgrade(candidates []*repo.Repo, force bool,
553-
ask bool) error {
553+
ask bool, noDeps bool) error {
554554

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

559-
vm, err := inst.calcVersionMap(candidates)
559+
vm, err := inst.calcVersionMap(candidates, noDeps)
560560
if err != nil {
561561
return err
562562
}
@@ -682,7 +682,7 @@ func (inst *Installer) Info(repos []*repo.Repo, remote bool) error {
682682
}
683683
}
684684

685-
vm, err := inst.calcVersionMap(repos)
685+
vm, err := inst.calcVersionMap(repos, false)
686686
if err != nil {
687687
return err
688688
}

newt/project/project.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ func (proj *Project) UpgradeIf(
332332
return err
333333
}
334334

335-
return inst.Upgrade(specifiedRepoList, force, ask)
335+
return inst.Upgrade(specifiedRepoList, force, ask, len(okRepos) > 0)
336336
}
337337

338338
func (proj *Project) InfoIf(predicate func(r *repo.Repo) bool,

0 commit comments

Comments
 (0)