Keep options in a fixed order, and say which block a diff hunk is in
Options of a block (server options, a view, a zone) are listed and
written grouped by topic, alphabetical within a group, so the same
option is in the same place everywhere. Top-level statements keep the
order they were added in.
named.conf diffs add the enclosing blocks to each hunk header, like
git's function context: @@ -50,6 +49,8 @@ view "internal" {.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
73d97ecc0a
commit
b097e10bef
9 files changed
+326
-3
No files matched your search
@@ -506,7 +506,9 @@ func (s *State) ServedRecordsByZone() map[int64][]*Record {
|
||||
return out
|
||||
}
|
||||
|
||||
// ScopedOptions returns the options of a scope, in position order.
|
||||
// ScopedOptions returns the options of a scope: in a fixed order by name
|
||||
// for a block (see optionLess), in the order they were added for
|
||||
// top-level statements, which are written as entered.
|
||||
func (s *State) ScopedOptions(scope string, scopeID int64) []*Option {
|
||||
var out []*Option
|
||||
for _, o := range s.Options {
|
||||
@@ -514,6 +516,10 @@ func (s *State) ScopedOptions(scope string, scopeID int64) []*Option {
|
||||
out = append(out, o)
|
||||
}
|
||||
}
|
||||
if scope != ScopeTopLevel {
|
||||
sort.Slice(out, func(i, j int) bool { return optionLess(out[i], out[j]) })
|
||||
return out
|
||||
}
|
||||
sort.Slice(out, func(i, j int) bool {
|
||||
if out[i].Position != out[j].Position {
|
||||
return out[i].Position < out[j].Position
|
||||
|
||||
Reference in new issue
Block a user