summaryrefslogtreecommitdiff
path: root/vendor/github.com/google/yamlfmt/engine/consecutive_engine.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-24 17:40:45 -0600
committermo khan <mo@mokhan.ca>2025-07-24 17:40:45 -0600
commitd48fe690c3c071cb5c8e3aa4d4672a32230a5e2d (patch)
tree414f9e91877e901cb3de12be6f466cb4929f55ab /vendor/github.com/google/yamlfmt/engine/consecutive_engine.go
parent7257c213887c6a80f727642b016606ec10340ed9 (diff)
refactor: extract job to process relationship updates in background
Diffstat (limited to 'vendor/github.com/google/yamlfmt/engine/consecutive_engine.go')
-rw-r--r--vendor/github.com/google/yamlfmt/engine/consecutive_engine.go21
1 files changed, 17 insertions, 4 deletions
diff --git a/vendor/github.com/google/yamlfmt/engine/consecutive_engine.go b/vendor/github.com/google/yamlfmt/engine/consecutive_engine.go
index 650d1b7..1ec241a 100644
--- a/vendor/github.com/google/yamlfmt/engine/consecutive_engine.go
+++ b/vendor/github.com/google/yamlfmt/engine/consecutive_engine.go
@@ -19,15 +19,17 @@ import (
"os"
"github.com/google/yamlfmt"
+ "github.com/google/yamlfmt/internal/logger"
)
// Engine that will process each file one by one consecutively.
type ConsecutiveEngine struct {
LineSepCharacter string
Formatter yamlfmt.Formatter
- Quiet bool
ContinueOnError bool
OutputFormat EngineOutputFormat
+ Quiet bool
+ Verbose bool
}
func (e *ConsecutiveEngine) FormatContent(content []byte) ([]byte, error) {
@@ -36,6 +38,13 @@ func (e *ConsecutiveEngine) FormatContent(content []byte) ([]byte, error) {
func (e *ConsecutiveEngine) Format(paths []string) (fmt.Stringer, error) {
formatDiffs, formatErrs := e.formatAll(paths)
+
+ // Debug format diff output.
+ logger.Debug(
+ logger.DebugCodeDiffs,
+ fmt.Sprintf("The following files were modified:\n%s", formatDiffs.StrOutput()),
+ )
+
if len(formatErrs) > 0 {
if e.ContinueOnError {
fmt.Print(formatErrs)
@@ -44,7 +53,11 @@ func (e *ConsecutiveEngine) Format(paths []string) (fmt.Stringer, error) {
return nil, formatErrs
}
}
- return nil, formatDiffs.ApplyAll()
+ applyErr := formatDiffs.ApplyAll()
+ if applyErr != nil {
+ return nil, applyErr
+ }
+ return getEngineOutput(e.OutputFormat, yamlfmt.OperationFormat, formatDiffs, e.Quiet, e.Verbose)
}
func (e *ConsecutiveEngine) Lint(paths []string) (fmt.Stringer, error) {
@@ -55,7 +68,7 @@ func (e *ConsecutiveEngine) Lint(paths []string) (fmt.Stringer, error) {
if formatDiffs.ChangedCount() == 0 {
return nil, nil
}
- return getEngineOutput(e.OutputFormat, yamlfmt.OperationLint, formatDiffs, e.Quiet)
+ return getEngineOutput(e.OutputFormat, yamlfmt.OperationLint, formatDiffs, e.Quiet, e.Verbose)
}
func (e *ConsecutiveEngine) DryRun(paths []string) (fmt.Stringer, error) {
@@ -66,7 +79,7 @@ func (e *ConsecutiveEngine) DryRun(paths []string) (fmt.Stringer, error) {
if formatDiffs.ChangedCount() == 0 {
return nil, nil
}
- return getEngineOutput(e.OutputFormat, yamlfmt.OperationDry, formatDiffs, e.Quiet)
+ return getEngineOutput(e.OutputFormat, yamlfmt.OperationDry, formatDiffs, e.Quiet, e.Verbose)
}
func (e *ConsecutiveEngine) formatAll(paths []string) (yamlfmt.FileDiffs, FormatErrors) {