Skip to content

Commit

Permalink
style: invert if statement
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Sep 27, 2023
1 parent 9a645b4 commit aba7409
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions internal/client/git.go
Expand Up @@ -97,15 +97,16 @@ func (g *gitClient) CreateFiles(
}); err != nil {
return fmt.Errorf("git: failed to setup local repository: %w", err)
}
if g.branch != "" {
if g.branch == "" {
return nil
}
if err := runGitCmds(ctx, cwd, env, [][]string{
{"checkout", g.branch},
}); err != nil {
if err := runGitCmds(ctx, cwd, env, [][]string{
{"checkout", g.branch},
{"checkout", "-b", g.branch},
}); err != nil {
if err := runGitCmds(ctx, cwd, env, [][]string{
{"checkout", "-b", g.branch},
}); err != nil {
return fmt.Errorf("git: could not checkout branch %s: %w", g.branch, err)
}
return fmt.Errorf("git: could not checkout branch %s: %w", g.branch, err)
}
}
return nil
Expand Down

0 comments on commit aba7409

Please sign in to comment.