Merge branch 'gmh-fix-commandless--update-panic' into 'main'

fix: Preventing a panic when not using a sub command

Closes #1371

See merge request https://gitlab.com/gitlab-org/cli/-/merge_requests/1304

Merged-by: Jay McCure <jmccure@gitlab.com>
Approved-by: Jay McCure <jmccure@gitlab.com>
Co-authored-by: Gary Holtz <gholtz@gitlab.com>
This commit is contained in:
Jay McCure 2023-06-28 23:10:22 +00:00
commit c1b3f9ed21
1 changed files with 10 additions and 1 deletions

View File

@ -162,7 +162,16 @@ func main() {
checkUpdate, _ := cfg.Get("", "check_update")
if checkUpdate, err := strconv.ParseBool(checkUpdate); err == nil && checkUpdate {
err = update.CheckUpdate(cmdFactory, version, true, expandedArgs[0])
var argCommand string
if expandedArgs != nil {
argCommand = expandedArgs[0]
} else {
argCommand = ""
}
err = update.CheckUpdate(cmdFactory, version, true, argCommand)
if err != nil {
printError(cmdFactory.IO, err, rootCmd, debug, false)
}