launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26415
[Merge] ~cjwatson/launchpad:py3-stable-git-permissions into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-stable-git-permissions into launchpad:master.
Commit message:
Stabilize sorting of rules in GitRepositoryPermissionsView
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398640
TestGitRepositoryPermissionsView.test_save_add_rules sometimes failed on Python 3 because of different ordering of a form encoding new rules for "refs/heads/*" and "refs/tags/1.0", and the existing sorting didn't have a tie-breaker for that. Add a tie-breaker for the prefix of the pattern.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-stable-git-permissions into launchpad:master.
diff --git a/lib/lp/code/browser/gitrepository.py b/lib/lp/code/browser/gitrepository.py
index 89600f9..31f7a14 100644
--- a/lib/lp/code/browser/gitrepository.py
+++ b/lib/lp/code/browser/gitrepository.py
@@ -1262,7 +1262,7 @@ class GitRepositoryPermissionsView(LaunchpadFormView):
# already been deleted by somebody else.
ordered_rules.append((ref_pattern, parsed_rule, rule.position))
ordered_rules.sort(
- key=lambda item: (item[1]["action"] != "add", item[2]))
+ key=lambda item: (item[1]["action"] != "add", item[2], item[0]))
for ref_pattern, parsed_rule, position in ordered_rules:
rule = rule_map.get(parsed_rule["pattern"])