mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-12 03:21:33 +00:00
Merge pull request #803 from stb-tester/deterministic-stanza-WriteTo
Stanza.WriteTo: Sort extra fields alphabetically
This commit is contained in:
1
AUTHORS
1
AUTHORS
@@ -34,3 +34,4 @@ List of contributors, in chronological order:
|
||||
* Maximilian Stein (https://github.com/steinymity)
|
||||
* Strajan Sebastian (https://github.com/strajansebastian)
|
||||
* Artem Smirnov (https://github.com/urpylka)
|
||||
* William Manley (https://github.com/wmanley)
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"io"
|
||||
"sort"
|
||||
"strings"
|
||||
"unicode"
|
||||
)
|
||||
@@ -182,8 +183,16 @@ func (s Stanza) WriteTo(w *bufio.Writer, isSource, isRelease, isInstaller bool)
|
||||
|
||||
// no extra fields in installer
|
||||
if !isInstaller {
|
||||
for field, value := range s {
|
||||
err := writeField(w, field, value, isRelease)
|
||||
// Print extra fields in deterministic order (alphabetical)
|
||||
keys := make([]string, len(s))
|
||||
i := 0
|
||||
for field := range s {
|
||||
keys[i] = field
|
||||
i++
|
||||
}
|
||||
sort.Strings(keys)
|
||||
for _, field := range keys {
|
||||
err := writeField(w, field, s[field], isRelease)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user