Use unique versions in staggered versioner (fixes #1063)

This commit is contained in:
Audrius Butkevicius
2014-12-02 18:53:38 +00:00
parent bc8907e90d
commit 3cbe92d797
3 changed files with 17 additions and 7 deletions

View File

@@ -18,6 +18,7 @@ package versioner
import (
"path/filepath"
"regexp"
"sort"
)
// Inserts ~tag just before the extension of the filename.
@@ -40,3 +41,17 @@ func filenameTag(path string) string {
}
return match[1]
}
func uniqueSortedStrings(strings []string) []string {
seen := make(map[string]struct{}, len(strings))
unique := make([]string, 0, len(strings))
for _, str := range strings {
_, ok := seen[str]
if !ok {
seen[str] = struct{}{}
unique = append(unique, str)
}
}
sort.Strings(unique)
return unique
}