Skip to content

Commit

Permalink
gluon-web-autoupdater: use human-readable names as branch labels, sor…
Browse files Browse the repository at this point in the history
…t by label

Use the value of the `name` site.conf field as label (it was
accidentally unused before).

Our site.conf currently doesn't define a specific order for the branch
entries. To avoid changing branch orders, sort entries by this label.

Fixes: freifunk-gluon#1961
  • Loading branch information
neocturne authored and mweinelt committed Apr 26, 2020
1 parent 4265039 commit 696b431
Showing 1 changed file with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,18 @@ function o:write(data)
end

o = s:option(ListValue, "branch", translate("Branch"))
uci:foreach("autoupdater", "branch",
function (section)
o:value(section[".name"])
end
)

local branches = {}
uci:foreach("autoupdater", "branch", function(branch)
table.insert(branches, branch)
end)
table.sort(branches, function(a, b)
return a.name < b.name
end)
for _, branch in ipairs(branches) do
o:value(branch[".name"], branch.name)
end

o.default = uci:get("autoupdater", autoupdater, "branch")
function o:write(data)
uci:set("autoupdater", autoupdater, "branch", data)
Expand Down

0 comments on commit 696b431

Please sign in to comment.