Skip to content

Commit 44d284d

Browse files
committed
ensure glob entries are sorted
This gives us stable results, which is useful during debugging and in tests
1 parent e6e2996 commit 44d284d

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/oxide/src/glob.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub fn optimize_patterns(entries: &Vec<GlobEntry>) -> Vec<GlobEntry> {
9797
// 1. All base paths in the pattern_map, that start with the current base path, can be removed.
9898
// 2. All patterns that are not `**/*` can be removed from the current base path.
9999

100-
pattern_map
100+
let mut glob_entries = pattern_map
101101
.into_iter()
102102
.map(|(base, patterns)| {
103103
let size = patterns.len();
@@ -116,7 +116,12 @@ pub fn optimize_patterns(entries: &Vec<GlobEntry>) -> Vec<GlobEntry> {
116116
},
117117
}
118118
})
119-
.collect::<Vec<GlobEntry>>()
119+
.collect::<Vec<GlobEntry>>();
120+
121+
// Sort the entries by base path to ensure we have stable results.
122+
glob_entries.sort_by(|a, z| a.base.cmp(&z.base));
123+
124+
glob_entries
120125
}
121126

122127
// Split a glob pattern into a `static` and `dynamic` part.

0 commit comments

Comments
 (0)