From e01fcff9a4884cbb5a2e1f1d80c5f3ffb77000c1 Mon Sep 17 00:00:00 2001 From: Jarek Kowalski Date: Sun, 27 Aug 2017 14:49:15 -0700 Subject: [PATCH] fixed sorting of synthetic fs.Entries --- fs/entry.go | 7 +++++++ fs/repofs/all_sources.go | 1 + fs/repofs/source_directories.go | 2 ++ fs/repofs/source_snapshots.go | 1 + 4 files changed, 11 insertions(+) diff --git a/fs/entry.go b/fs/entry.go index fc485233a..2d0a6d005 100644 --- a/fs/entry.go +++ b/fs/entry.go @@ -55,6 +55,13 @@ func (e Entries) FindByName(n string) Entry { return nil } +// Sort sorts the entries by name. +func (e Entries) Sort() { + sort.Slice(e, func(i, j int) bool { + return e[i].Metadata().Name < e[j].Metadata().Name + }) +} + // EntryPath returns a path of a given entry from its root node. func EntryPath(e Entry) string { var parts []string diff --git a/fs/repofs/all_sources.go b/fs/repofs/all_sources.go index 3281e63cc..84d5b9200 100644 --- a/fs/repofs/all_sources.go +++ b/fs/repofs/all_sources.go @@ -48,6 +48,7 @@ func (s *repositoryAllSources) Readdir() (fs.Entries, error) { }) } + result.Sort() return result, nil } diff --git a/fs/repofs/source_directories.go b/fs/repofs/source_directories.go index d2f828ed1..00b0ee0b7 100644 --- a/fs/repofs/source_directories.go +++ b/fs/repofs/source_directories.go @@ -44,5 +44,7 @@ func (s *sourceDirectories) Readdir() (fs.Entries, error) { result = append(result, &sourceSnapshots{s, s.repo, s.snapshotManager, src}) } + result.Sort() + return result, nil } diff --git a/fs/repofs/source_snapshots.go b/fs/repofs/source_snapshots.go index d68621d8a..68ecf01b7 100644 --- a/fs/repofs/source_snapshots.go +++ b/fs/repofs/source_snapshots.go @@ -59,6 +59,7 @@ func (s *sourceSnapshots) Readdir() (fs.Entries, error) { result = append(result, e) } + result.Sort() return result, nil }