launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #30312
[Merge] ~ines-almeida/launchpad:ensure-no-duplicate-git-refs into launchpad:master
Ines Almeida has proposed merging ~ines-almeida/launchpad:ensure-no-duplicate-git-refs into launchpad:master.
Commit message:
Sort and remove duplicates in CIBuild.git_refs
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/447658
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:ensure-no-duplicate-git-refs into launchpad:master.
diff --git a/lib/lp/code/model/cibuild.py b/lib/lp/code/model/cibuild.py
index 0634d50..edddef8 100644
--- a/lib/lp/code/model/cibuild.py
+++ b/lib/lp/code/model/cibuild.py
@@ -280,7 +280,7 @@ class CIBuild(PackageBuildMixin, StormBase):
self.build_farm_job = build_farm_job
self.git_repository = git_repository
self.commit_sha1 = commit_sha1
- self.git_refs = git_refs
+ self.git_refs = sorted(git_refs) if git_refs is not None else None
self.distro_arch_series = distro_arch_series
self.processor = processor
self.virtualized = virtualized
@@ -754,7 +754,7 @@ class CIBuildSet(SpecificBuildFarmJobSourceMixin):
for cibuild in result:
if cibuild.git_refs is None:
cibuild.git_refs = []
- cibuild.git_refs.extend(git_refs)
+ cibuild.git_refs = sorted(set(cibuild.git_refs + git_refs))
raise CIBuildAlreadyRequested
build = self.new(
diff --git a/lib/lp/code/model/tests/test_cibuild.py b/lib/lp/code/model/tests/test_cibuild.py
index bc3fd83..0847d23 100644
--- a/lib/lp/code/model/tests/test_cibuild.py
+++ b/lib/lp/code/model/tests/test_cibuild.py
@@ -815,7 +815,7 @@ class TestCIBuildSet(TestCaseWithFactory):
self.assertTrue(build_queue.virtualized)
self.assertIsNone(build_queue.builder_constraints)
self.assertEqual(BuildQueueStatus.WAITING, build_queue.status)
- self.assertEqual(git_refs, build.git_refs)
+ self.assertEqual(sorted(git_refs), build.git_refs)
# Rescheduling a build for the same commit_sha1 raises an error, but
# git_refs of the build are updated
@@ -826,10 +826,10 @@ class TestCIBuildSet(TestCaseWithFactory):
commit_sha1,
das,
stages,
- ["ref/bar"],
+ ["ref/test", "ref/bar"],
)
git_refs.append("ref/bar")
- self.assertEqual(git_refs, build.git_refs)
+ self.assertEqual(sorted(git_refs), build.git_refs)
def test_requestBuild_score(self):
# CI builds have an initial queue score of 2600.