Skip to content

Commit 6d15cb3

Browse files
committed
Fix SaveCmd.AfterApply context binding
kong.Parse calls AfterApply hooks during parsing, before kctx.BindTo has a chance to run. SaveCmd.AfterApply(ctx context.Context) needs a bound context to resolve HEAD via gitHead(). Move the BindTo call into the Parse options so the binding is available during AfterApply.
1 parent 0597b51 commit 6d15cb3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

cmd/gradle-cache/main.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,13 @@ func projectDirSources(projectDir string, includedBuilds []string) []tarSource {
345345

346346
func main() {
347347
cli := &CLI{}
348-
kctx := kong.Parse(cli, kong.UsageOnError(), kong.HelpOptions{Compact: true})
349-
setupLogger(cli.LogLevel)
350348
ctx := context.Background()
351-
kctx.BindTo(ctx, (*context.Context)(nil))
349+
kctx := kong.Parse(cli,
350+
kong.UsageOnError(),
351+
kong.HelpOptions{Compact: true},
352+
kong.BindTo(ctx, (*context.Context)(nil)), // needed by SaveCmd.AfterApply
353+
)
354+
setupLogger(cli.LogLevel)
352355
kctx.FatalIfErrorf(kctx.Run(ctx))
353356
}
354357

0 commit comments

Comments
 (0)