Skip to content

Commit

Permalink
Merge pull request #11664 from jhrotko/fix-no-build-watch
Browse files Browse the repository at this point in the history
Handle --no-build and --watch args
  • Loading branch information
glours committed Mar 27, 2024
2 parents 4b7b6ad + dd5614e commit 6fe69b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/compose/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func upCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service, ex
return upCmd
}

//nolint:gocyclo
func validateFlags(up *upOptions, create *createOptions) error {
if up.exitCodeFrom != "" {
up.cascadeStop = true
Expand All @@ -159,6 +160,9 @@ func validateFlags(up *upOptions, create *createOptions) error {
if create.recreateDeps && create.noRecreate {
return fmt.Errorf("--always-recreate-deps and --no-recreate are incompatible")
}
if create.noBuild && up.watch {
return fmt.Errorf("--no-build and --watch are incompatible")
}
return nil
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/formatter/shortcut.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,12 @@ func (lk *LogKeyboard) StartWatch(ctx context.Context, project *types.Project, o
} else {
eg.Go(tracing.EventWrapFuncForErrGroup(ctx, "menu/watch", tracing.SpanOptions{},
func(ctx context.Context) error {
if options.Create.Build == nil {
err := fmt.Errorf("Cannot run watch mode with flag --no-build")
lk.keyboardError("Watch", err)
return err
}

lk.Watch.newContext(ctx)
buildOpts := *options.Create.Build
buildOpts.Quiet = true
Expand Down

0 comments on commit 6fe69b2

Please sign in to comment.