From 41d246ce1a6f47d950a4cae0f8f28b45f1b9e79b Mon Sep 17 00:00:00 2001 From: x2 Date: Sun, 1 Sep 2024 15:20:27 -0500 Subject: [PATCH 1/2] Add missing arg length check to fix runtime panic on "repo branch delete " command with missing branch arg --- pkg/ssh/cmd/branch.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/ssh/cmd/branch.go b/pkg/ssh/cmd/branch.go index c43ce974..daa0efaa 100644 --- a/pkg/ssh/cmd/branch.go +++ b/pkg/ssh/cmd/branch.go @@ -148,6 +148,7 @@ func branchDeleteCommand() *cobra.Command { Use: "delete REPOSITORY BRANCH", Aliases: []string{"remove", "rm", "del"}, Short: "Delete a branch", + Args: cobra.ExactArgs(2), PersistentPreRunE: checkIfCollab, RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() From 3dfcf176abcfc39e37c0422dd956934d3895249a Mon Sep 17 00:00:00 2001 From: x2 Date: Wed, 4 Sep 2024 01:36:54 -0500 Subject: [PATCH 2/2] Add testscript case for missing argument --- testscript/testdata/repo-delete.txtar | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/testscript/testdata/repo-delete.txtar b/testscript/testdata/repo-delete.txtar index 403c9604..ca513e78 100644 --- a/testscript/testdata/repo-delete.txtar +++ b/testscript/testdata/repo-delete.txtar @@ -10,6 +10,11 @@ soft repo create repo-to-delete soft repo delete repo-to-delete ! soft repo delete nope stderr '.*not found.*' + +# missing argument should fail +! soft repo branch delete repo1 +stderr 'Error.*accepts 2 arg.*' + soft repo list stdout 'repo1'