From d48fe690c3c071cb5c8e3aa4d4672a32230a5e2d Mon Sep 17 00:00:00 2001 From: mo khan Date: Thu, 24 Jul 2025 17:40:45 -0600 Subject: refactor: extract job to process relationship updates in background --- vendor/github.com/google/yamlfmt/engine.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'vendor/github.com/google/yamlfmt/engine.go') diff --git a/vendor/github.com/google/yamlfmt/engine.go b/vendor/github.com/google/yamlfmt/engine.go index b98ee89..bd43f0c 100644 --- a/vendor/github.com/google/yamlfmt/engine.go +++ b/vendor/github.com/google/yamlfmt/engine.go @@ -17,6 +17,7 @@ package yamlfmt import ( "fmt" "os" + "slices" "github.com/google/yamlfmt/internal/collections" "github.com/google/yamlfmt/internal/multilinediff" @@ -88,7 +89,9 @@ func (fds FileDiffs) Add(diff *FileDiff) error { func (fds FileDiffs) StrOutput() string { result := "" - for _, fd := range fds { + sortedPaths := fds.sortedPaths() + for _, path := range sortedPaths { + fd := fds[path] if fd.Diff.Changed() { result += fd.StrOutput() } @@ -98,7 +101,9 @@ func (fds FileDiffs) StrOutput() string { func (fds FileDiffs) StrOutputQuiet() string { result := "" - for _, fd := range fds { + sortedPaths := fds.sortedPaths() + for _, path := range sortedPaths { + fd := fds[path] if fd.Diff.Changed() { result += fd.StrOutputQuiet() } @@ -125,3 +130,12 @@ func (fds FileDiffs) ChangedCount() int { } return changed } + +func (fds FileDiffs) sortedPaths() []string { + pathKeys := []string{} + for path := range fds { + pathKeys = append(pathKeys, path) + } + slices.Sort(pathKeys) + return pathKeys +} -- cgit v1.2.3