diff --git a/.github/newt_upgrade/allowed-ignored/expected.txt b/.github/newt_upgrade/allowed-ignored/expected.txt index 571ed69fe2..2951299b66 100644 --- a/.github/newt_upgrade/allowed-ignored/expected.txt +++ b/.github/newt_upgrade/allowed-ignored/expected.txt @@ -4,3 +4,4 @@ arm-CMSIS_5 mcuboot nordic-nrfx stm-stm32g4xx_hal_driver +tinyusb diff --git a/.github/newt_upgrade/fail/core-ignored/expected.txt b/.github/newt_upgrade/fail/core-ignored/expected.txt index af5781a97d..1fec74193b 100644 --- a/.github/newt_upgrade/fail/core-ignored/expected.txt +++ b/.github/newt_upgrade/fail/core-ignored/expected.txt @@ -1 +1 @@ -Error: apache-mynewt-core repository must be allowed. Please add it to the allowed list and/or remove it from the ignored list. +Error: apache-mynewt-core repository cannot be on ignored list. diff --git a/.github/newt_upgrade/fail/core-not-allowed/expected.txt b/.github/newt_upgrade/fail/core-not-allowed/expected.txt deleted file mode 100644 index af5781a97d..0000000000 --- a/.github/newt_upgrade/fail/core-not-allowed/expected.txt +++ /dev/null @@ -1 +0,0 @@ -Error: apache-mynewt-core repository must be allowed. Please add it to the allowed list and/or remove it from the ignored list. diff --git a/.github/newt_upgrade/fail/core-not-allowed/project.yml b/.github/newt_upgrade/fail/core-not-allowed/project.yml deleted file mode 100644 index 588caf339d..0000000000 --- a/.github/newt_upgrade/fail/core-not-allowed/project.yml +++ /dev/null @@ -1,31 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -project.repositories: - - apache-mynewt-core - -repository.apache-mynewt-core: - type: github - vers: 0-dev - user: apache - repo: mynewt-core - -project.repositories.allowed: - - apache-mynewt-nimble - - apache-mynewt-mcumgr diff --git a/newt/project/project.go b/newt/project/project.go index 2bafb42fcc..48ac577421 100644 --- a/newt/project/project.go +++ b/newt/project/project.go @@ -192,6 +192,10 @@ func (proj *Project) patternsMatch(patterns *[]*regexp.Regexp, repoName string) return false } +func (proj *Project) isRepoIgnored(repoName string) bool { + return proj.patternsMatch(&proj.reposIgnoredRe, repoName) +} + func (proj *Project) isRepoAllowed(repoName string) bool { if (len(proj.reposAllowedRe) == 0) || proj.patternsMatch(&proj.reposAllowedRe, repoName) { return !proj.patternsMatch(&proj.reposIgnoredRe, repoName) @@ -219,6 +223,10 @@ func (proj *Project) GetPkgRepos() error { fields, err := pkg.PkgConfig().GetValStringMapString(k, nil) util.OneTimeWarningError(err) + if !proj.isRepoAllowed(repoName) { + continue + } + r, err := proj.loadRepo(repoName, fields) if err != nil { // if `repository.yml` does not exist, it is not an error; we @@ -437,10 +445,6 @@ func (proj *Project) InfoIf(predicate func(r *repo.Repo) bool, // @return error Error on failure. func (proj *Project) loadRepo(name string, fields map[string]string) ( *repo.Repo, error) { - - if !proj.isRepoAllowed(name) { - return nil, nil - } // First, read the repo description from the supplied fields. if fields["type"] == "" { return nil, @@ -523,6 +527,11 @@ func (proj *Project) loadRepoDeps(download bool) error { depRepo := proj.repos[dep.Name] if depRepo == nil { var err error + + if !proj.isRepoAllowed(dep.Name) { + continue + } + depRepo, err = proj.loadRepo(dep.Name, dep.Fields) if err != nil { // if `repository.yml` does not exist, it is not an @@ -720,18 +729,17 @@ func (proj *Project) loadConfig(download bool) error { reposAllowed, err = yc.GetValStringSlice("project.repositories.allowed", nil) util.OneTimeWarningError(err) - proj.reposAllowedRe, err = proj.createRegexpPatterns(reposAllowed) + proj.reposAllowedRe, err = proj.createRegexpPatterns(util.UniqueStrings(reposAllowed)) util.OneTimeWarningError(err) reposIgnored, err = yc.GetValStringSlice("project.repositories.ignored", nil) util.OneTimeWarningError(err) reposIgnored = append(reposIgnored, newtutil.NewtIgnore...) - proj.reposIgnoredRe, err = proj.createRegexpPatterns(reposIgnored) + proj.reposIgnoredRe, err = proj.createRegexpPatterns(util.UniqueStrings(reposIgnored)) util.OneTimeWarningError(err) - if !proj.isRepoAllowed("apache-mynewt-core") { - return util.NewNewtError("apache-mynewt-core repository must be allowed. " + - "Please add it to the allowed list and/or remove it from the ignored list.") + if proj.isRepoIgnored("apache-mynewt-core") { + return util.NewNewtError("apache-mynewt-core repository cannot be on ignored list.") } // Local repository always included in initialization @@ -754,6 +762,10 @@ func (proj *Project) loadConfig(download bool) error { fields, err := yc.GetValStringMapString(k, nil) util.OneTimeWarningError(err) + if proj.isRepoIgnored(repoName) { + continue + } + r, err := proj.loadRepo(repoName, fields) if err != nil { // if `repository.yml` does not exist, it is not an error; we