fix: add missing arg length check to fix runtime panic (#568)
Christopher David Shirk
and
x2
created
* Add missing arg length check to fix runtime panic on "repo branch delete <reponame>" command with missing branch arg
* Add testscript case for missing argument
---------
Co-authored-by: x2 <x2@rrotn.local>
Change summary
pkg/ssh/cmd/branch.go | 1 +
testscript/testdata/repo-delete.txtar | 5 +++++
2 files changed, 6 insertions(+)
Detailed changes
@@ -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()
@@ -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'