From f95ac6780f83b30d026f539fd1a4e41f26036ca0 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Fri, 27 Jun 2025 14:42:59 +0200 Subject: [PATCH] Cleanup: turn around error condition It is a common go convention for the "happy path" to be as little indented as possible. --- pkg/commands/git_commands/branch.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/commands/git_commands/branch.go b/pkg/commands/git_commands/branch.go index e634b27ec..6333d136e 100644 --- a/pkg/commands/git_commands/branch.go +++ b/pkg/commands/git_commands/branch.go @@ -111,10 +111,11 @@ func (self *BranchCommands) CurrentBranchName() (string, error) { ToArgv() output, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput() - if err == nil { - return strings.TrimSpace(output), nil + if err != nil { + return "", err } - return "", err + + return strings.TrimSpace(output), nil } // LocalDelete delete branch locally