Skip to content

Commit

Permalink
fix: add missing arg length check to fix runtime panic (#568)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
christophershirk and x2 authored Sep 9, 2024
1 parent c354d5f commit 85b4625
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/ssh/cmd/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Check failure on line 151 in pkg/ssh/cmd/branch.go

View workflow job for this annotation

GitHub Actions / lint-soft

Magic number: 2, in <argument> detected (mnd)
PersistentPreRunE: checkIfCollab,
RunE: func(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()
Expand Down
5 changes: 5 additions & 0 deletions testscript/testdata/repo-delete.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down

0 comments on commit 85b4625

Please sign in to comment.