Use en_US collator for sorting repo names This should be configurable but considering we don't internationalize any other part of the UI, e.g. strings or dates, do the simplest thing possible for now. Note that this applies only to repository names, which need to be sorted manually as we can't trust the filesystem to do so. For other sorted lists, e.g. tree contents and refs, use the ordering provided by JGit. Change-Id: I55dbb9f1ed3b5a20f56f6ea2535ac865c4256196
diff --git a/gitiles-servlet/src/main/java/com/google/gitiles/DefaultAccess.java b/gitiles-servlet/src/main/java/com/google/gitiles/DefaultAccess.java index 4c624d9..a89d6cb 100644 --- a/gitiles-servlet/src/main/java/com/google/gitiles/DefaultAccess.java +++ b/gitiles-servlet/src/main/java/com/google/gitiles/DefaultAccess.java
@@ -33,10 +33,12 @@ import java.io.File; import java.io.IOException; +import java.text.Collator; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Queue; import java.util.Set; @@ -56,6 +58,8 @@ private static final String DEFAULT_DESCRIPTION = "Unnamed repository; edit this file 'description' to name the repository."; + private static final Collator US_COLLATOR = Collator.getInstance(Locale.US); + public static class Factory implements GitilesAccess.Factory { private final File basePath; private final String canonicalBasePath; @@ -99,7 +103,7 @@ @Override public Map<String, RepositoryDescription> listRepositories(Set<String> branches) throws IOException { - Map<String, RepositoryDescription> repos = Maps.newTreeMap(); + Map<String, RepositoryDescription> repos = Maps.newTreeMap(US_COLLATOR); for (Repository repo : scanRepositories(basePath, req)) { repos.put(getRepositoryName(repo), buildDescription(repo, branches)); repo.close();