This is an automated email from the ASF dual-hosted git repository. ccollins pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit c9b5137025e8081b34401bfefed1ccef56287eb1 Author: Christopher Collins <[email protected]> AuthorDate: Mon Jan 13 17:18:52 2020 -0800 Allow repo hash to correspond to version number When resolving repo versions, newt uses this procedure: 1. Resolve inter-repo dependencies. 2. Resolve project.yml dependencies. Allow project.yml to override dependencies from step 1. There was a bug affecting both steps in the procedure. If a dependency specifies a commit hash that corresponds exactly to a version number, then the dependency was ignored. This commit fixes the problem so that commit hashes are always honored, whether or not they correspond to version numbers. --- newt/install/install.go | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/newt/install/install.go b/newt/install/install.go index 7ce2792..313b759 100644 --- a/newt/install/install.go +++ b/newt/install/install.go @@ -527,35 +527,6 @@ func (inst *Installer) installPrompt(vm deprepo.VersionMap, op installOp, } } -// Determines whether a repo version's `Commit` field should be maintained. If -// the commit corresponds exactly to a repo version in `repository.yml` (as -// opposed to simply indicating its version in a `version.yml` file), then the -// commit string should be discarded. If the commit string is kept, newt -// interprets the version as being different from the official release version, -// triggering an upgrade. -func (inst *Installer) shouldKeepCommit( - repoName string, commit string) (bool, error) { - - if commit == "" { - return false, nil - } - - r := inst.repos[repoName] - if r == nil { - return false, nil - } - - vers, err := r.VersFromEquivCommit(commit) - if err != nil { - return false, err - } - if len(vers) > 0 { - return false, nil - } - - return true, nil -} - // Filters out repos from a version map, keeping only those which are present // in the supplied slice. func filterVersionMap( @@ -604,12 +575,7 @@ func (inst *Installer) assignCommits(vm deprepo.VersionMap, repoName string, for _, req := range reqs { curVer := vm[repoName] if curVer.Satisfies(req) { - keep, err := inst.shouldKeepCommit(repoName, req.Ver.Commit) - if err != nil { - return err - } - - if keep { + if req.Ver.Commit != "" { prevCommit := vm[repoName].Commit newCommit := req.Ver.Commit @@ -676,7 +642,6 @@ func (inst *Installer) calcVersionMap(candidates []*repo.Repo) ( // Try to find a version set that satisfies the dependency graph. If no // such set exists, report the conflicts and abort. vm, conflicts := deprepo.FindAcceptableVersions(m, dg) - log.Debugf("Repo version map:\n%s\n", vm.String()) if len(conflicts) > 0 { return nil, deprepo.ConflictError(conflicts) } @@ -702,6 +667,9 @@ func (inst *Installer) calcVersionMap(candidates []*repo.Repo) ( } } + log.Debugf("repo version map after project.yml overrides:\n%s", + vm.String()) + // Now that we know which repo versions we want, we can eliminate some // false-positives from the repo list. repoList = inst.ensureDepsInList(candidates, vm)
