diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-24 17:40:45 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-24 17:40:45 -0600 |
| commit | d48fe690c3c071cb5c8e3aa4d4672a32230a5e2d (patch) | |
| tree | 414f9e91877e901cb3de12be6f466cb4929f55ab /vendor/github.com/google/yamlfmt/engine.go | |
| parent | 7257c213887c6a80f727642b016606ec10340ed9 (diff) | |
refactor: extract job to process relationship updates in background
Diffstat (limited to 'vendor/github.com/google/yamlfmt/engine.go')
| -rw-r--r-- | vendor/github.com/google/yamlfmt/engine.go | 18 |
1 files changed, 16 insertions, 2 deletions
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 +} |
