You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ja...@apache.org on 2026/10/20 19:30:37 UTC

(mynewt-newt) 07/15: newt/cli: Report unknown repository in newt info

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 53f2a59eb3426478b76b55f22ea2d96410919cab
Author: Szymon Janc <sz...@codecoup.pl>
AuthorDate: Mon Oct 19 17:50:24 2026 +0200

    newt/cli: Report unknown repository in newt info
    
    "newt info @nosuch" printed nothing and exited with status 0. Report
    an error if the requested repository is not known.
    
    Assisted-by: Claude:claude-opus-5-5
---
 newt/cli/project_cmds.go     |  7 +++++++
 newt/error_reporting_test.go | 15 +++++++++++++++
 2 files changed, 22 insertions(+)

diff --git a/newt/cli/project_cmds.go b/newt/cli/project_cmds.go
index 4caa9f21..e378956f 100644
--- a/newt/cli/project_cmds.go
+++ b/newt/cli/project_cmds.go
@@ -169,6 +169,13 @@ func infoRunCmd(cmd *cobra.Command, args []string) {
 	}
 	sort.Strings(repoNames)
 
+	if reqRepoName != "all" && proj.PackageList()[reqRepoName] == nil &&
+		proj.FindRepo(reqRepoName) == nil {
+
+		NewtUsage(nil, util.FmtNewtError("Unknown repository: @%s",
+			reqRepoName))
+	}
+
 	firstRepo := true
 	for _, repoName := range repoNames {
 		if reqRepoName == "all" || reqRepoName == repoName {
diff --git a/newt/error_reporting_test.go b/newt/error_reporting_test.go
index 4762ea7a..299f1fba 100644
--- a/newt/error_reporting_test.go
+++ b/newt/error_reporting_test.go
@@ -156,3 +156,18 @@ func TestErrorReportingMissingBspScript(t *testing.T) {
 			[]string{"does not specify bsp.debugscript"}, "debug", "app")
 	})
 }
+
+// "newt info" with an unknown repository must fail.
+func TestErrorReportingInfoUnknownRepo(t *testing.T) {
+	errorReportingExpectFail(t, errorReportingProjDir,
+		[]string{"Unknown repository: @nosuch"}, "info", "@nosuch")
+
+	for _, r := range []string{"@apache-mynewt-core", "error_reporting",
+		"all"} {
+
+		out := newtOutput(t, errorReportingProjDir, nil, "info", r)
+		if !strings.Contains(out, "Packages in @") {
+			t.Errorf("newt info %s: no packages listed\n%s", r, out)
+		}
+	}
+}