Skip to content

Commit

Permalink
fix: pass verbose pointer instead of copy
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddi committed Nov 29, 2024
1 parent 6af501d commit 5c1edda
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion contribs/github-bot/internal/check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func execCheck(flags *checkFlags) error {
gh, err := client.New(ctx, &client.Config{
Owner: flags.Owner,
Repo: flags.Repo,
Verbose: flags.Verbose,
Verbose: *flags.Verbose,
DryRun: flags.DryRun,
})

Check warning on line 35 in contribs/github-bot/internal/check/check.go

View check run for this annotation

Codecov / codecov/patch

contribs/github-bot/internal/check/check.go#L30-L35

Added lines #L30 - L35 were not covered by tests
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions contribs/github-bot/internal/check/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ type checkFlags struct {
Repo string
PRAll bool
PRNums utils.PRList
Verbose bool
Verbose *bool
DryRun bool
Timeout time.Duration
flagSet *flag.FlagSet
}

func NewCheckCmd(verbose bool) *commands.Command {
func NewCheckCmd(verbose *bool) *commands.Command {
flags := &checkFlags{Verbose: verbose}

return commands.NewCommand(
Expand Down
4 changes: 2 additions & 2 deletions contribs/github-bot/internal/matrix/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
)

type matrixFlags struct {
verbose bool
verbose *bool
matrixKey string
flagSet *flag.FlagSet
}

func NewMatrixCmd(verbose bool) *commands.Command {
func NewMatrixCmd(verbose *bool) *commands.Command {
flags := &matrixFlags{verbose: verbose}

return commands.NewCommand(
Expand Down
6 changes: 3 additions & 3 deletions contribs/github-bot/internal/matrix/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func execMatrix(flags *matrixFlags) error {
}

// If verbose is set, print the Github Actions event for debugging purpose.
if flags.verbose {
if *flags.verbose {
fmt.Println("Event:", actionCtx.Event)
}

Check warning on line 25 in contribs/github-bot/internal/matrix/matrix.go

View check run for this annotation

Codecov / codecov/patch

contribs/github-bot/internal/matrix/matrix.go#L23-L25

Added lines #L23 - L25 were not covered by tests

Expand All @@ -29,7 +29,7 @@ func execMatrix(flags *matrixFlags) error {
gh, err := client.New(context.Background(), &client.Config{
Owner: owner,
Repo: repo,
Verbose: flags.verbose,
Verbose: *flags.verbose,
DryRun: true,
})

Check warning on line 34 in contribs/github-bot/internal/matrix/matrix.go

View check run for this annotation

Codecov / codecov/patch

contribs/github-bot/internal/matrix/matrix.go#L29-L34

Added lines #L29 - L34 were not covered by tests
if err != nil {
Expand All @@ -50,7 +50,7 @@ func execMatrix(flags *matrixFlags) error {
matrix := fmt.Sprintf("%s=[%s]", flags.matrixKey, string(bytes))

// If verbose is set, print the matrix for debugging purpose.
if flags.verbose {
if *flags.verbose {
fmt.Printf("Matrix: %s\n", matrix)
}

Check warning on line 55 in contribs/github-bot/internal/matrix/matrix.go

View check run for this annotation

Codecov / codecov/patch

contribs/github-bot/internal/matrix/matrix.go#L50-L55

Added lines #L50 - L55 were not covered by tests

Expand Down
4 changes: 2 additions & 2 deletions contribs/github-bot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func main() {
)

cmd.AddSubCommands(
check.NewCheckCmd(flags.verbose),
matrix.NewMatrixCmd(flags.verbose),
check.NewCheckCmd(&flags.verbose),
matrix.NewMatrixCmd(&flags.verbose),
)

cmd.Execute(context.Background(), os.Args[1:])
Expand Down

0 comments on commit 5c1edda

Please sign in to comment.