Skip to content

Commit

Permalink
feat: prepend branchname on verbose output
Browse files Browse the repository at this point in the history
  • Loading branch information
sascha-andres committed Apr 14, 2023
1 parent defbd38 commit 7640942
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions internal/builder/commit_message_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"bytes"
"errors"
"fmt"
"github.com/manifoldco/promptui"
"github.com/sascha-andres/gitc/internal"
"io"
"log"
"os"
"regexp"
"strings"

"github.com/manifoldco/promptui"
"github.com/sascha-andres/gitc/internal"
)

var (
Expand Down Expand Up @@ -121,11 +120,9 @@ func (cmb *CommitMessageBuilder) Build() error {
}

var branchBuffer bytes.Buffer
_, err = internal.Git(&branchBuffer, "branch", "--show-current")
if cmb.verbose {
writer := io.MultiWriter(os.Stdout, &branchBuffer)
_, err = internal.Git(writer, "branch", "--show-current")
} else {
_, err = internal.Git(&branchBuffer, "branch", "--show-current")
log.Printf("found branch: %q", strings.TrimSpace(branchBuffer.String()))
}
if err != nil {
return fmt.Errorf("could not read current branch: %w", err)
Expand Down

0 comments on commit 7640942

Please sign in to comment.