This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit c90780911e56433a447c39b5aa2aca3d86bbff3d
Author: Szymon Janc <[email protected]>
AuthorDate: Mon Oct 19 17:55:08 2026 +0200

    newt/project: Warn about nested repository map in project.yml
    
    Repositories must be defined with "repository.<name>" keys. A nested
    "repository: {<name>: {...}}" map was silently ignored. Warn about it.
    
    Assisted-by: Claude:claude-opus-5-5
---
 newt/error_reporting_test.go | 21 +++++++++++++++++++++
 newt/project/project.go      |  7 +++++++
 2 files changed, 28 insertions(+)

diff --git a/newt/error_reporting_test.go b/newt/error_reporting_test.go
index 9d7ab1c1..e479931d 100644
--- a/newt/error_reporting_test.go
+++ b/newt/error_reporting_test.go
@@ -218,3 +218,24 @@ func TestErrorReportingNonMapSyscfg(t *testing.T) {
                })
        }
 }
+
+// Nested "repository" map in project.yml is not supported and must be
+// reported instead of being silently ignored.
+func TestErrorReportingNestedRepository(t *testing.T) {
+       dir := t.TempDir()
+       errorReportingWriteFiles(t, dir, map[string]string{
+               "project.yml": "project.name: test\n" +
+                       "repository:\n" +
+                       "    apache-mynewt-core:\n" +
+                       "        type: git\n" +
+                       "        vers: 0.0.0\n" +
+                       "        url: https://dummy.invalid/core.git\n";,
+       })
+
+       out, _ := newtCombinedOutput(dir, nil, "info")
+       msg := `project.yml: ignoring "repository"; each repository must be ` +
+               "defined with a separate"
+       if !strings.Contains(out, "WARNING: "+msg) {
+               t.Errorf("missing warning\n%s", out)
+       }
+}
diff --git a/newt/project/project.go b/newt/project/project.go
index 2a04e63f..298abffd 100644
--- a/newt/project/project.go
+++ b/newt/project/project.go
@@ -848,6 +848,13 @@ func (proj *Project) loadConfig(download bool) error {
        // Assume every item starting with "repository." is a repository 
descriptor
        // and try to load it.
        for k, _ := range yc.AllSettings() {
+               if k == "repository" {
+                       util.OneTimeWarning("%s: ignoring \"repository\"; each 
"+
+                               "repository must be defined with a separate "+
+                               "\"repository.<name>\" key", PROJECT_FILE_NAME)
+                       continue
+               }
+
                repoName := strings.TrimPrefix(k, "repository.")
                if repoName != k {
                        fields, err := yc.GetValStringMapString(k, nil)

Reply via email to