launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #22870
[Merge] lp:~twom/launchpad/pending-but-not-merged into lp:launchpad
Tom Wardill has proposed merging lp:~twom/launchpad/pending-but-not-merged into lp:launchpad.
Commit message:
Don't show merged or otherwise inactive landing targets on the gitrepository page
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/pending-but-not-merged/+merge/354108
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~twom/launchpad/pending-but-not-merged into lp:launchpad.
=== modified file 'lib/lp/code/browser/gitrepository.py'
--- lib/lp/code/browser/gitrepository.py 2018-08-30 14:54:37 +0000
+++ lib/lp/code/browser/gitrepository.py 2018-08-31 11:44:12 +0000
@@ -397,6 +397,12 @@
targets = self.context.getPrecachedLandingTargets(self.user)
return latest_proposals_for_each_branch(targets)
+ @cachedproperty
+ def active_landing_targets(self):
+ targets = self.context.getPrecachedLandingTargets(
+ self.user, ignore_merged=True)
+ return latest_proposals_for_each_branch(targets)
+
class GitRepositoryEditFormView(LaunchpadEditFormView):
"""Base class for forms that edit a Git repository."""
=== modified file 'lib/lp/code/browser/tests/test_gitrepository.py'
--- lib/lp/code/browser/tests/test_gitrepository.py 2018-08-31 06:29:29 +0000
+++ lib/lp/code/browser/tests/test_gitrepository.py 2018-08-31 11:44:12 +0000
@@ -296,6 +296,27 @@
self.assertIsNotNone(
find_tag_by_id(browser.contents, 'landing-targets'))
+ def test_view_with_inactive_landing_targets(self):
+ product = self.factory.makeProduct(name="foo", vcs=VCSType.GIT)
+ target_repository = self.factory.makeGitRepository(target=product)
+ source_repository = self.factory.makeGitRepository(target=product)
+ target_git_refs = self.factory.makeGitRefs(
+ target_repository,
+ paths=["refs/heads/master", "refs/heads/1.0", "refs/tags/1.1"])
+ source_git_refs = self.factory.makeGitRefs(
+ source_repository,
+ paths=["refs/heads/master"])
+ self.factory.makeBranchMergeProposalForGit(
+ target_ref=target_git_refs[0],
+ source_ref=source_git_refs[0],
+ set_state=BranchMergeProposalStatus.MERGED)
+ with FeatureFixture({"code.git.show_repository_mps": "on"}):
+ with person_logged_in(target_repository.owner):
+ browser = self.getViewBrowser(
+ source_repository, user=source_repository.owner)
+ self.assertIsNone(
+ find_tag_by_id(browser.contents, 'landing-targets'))
+
class TestGitRepositoryViewPrivateArtifacts(BrowserTestCase):
"""Tests that Git repositories with private team artifacts can be viewed.
=== modified file 'lib/lp/code/model/gitrepository.py'
--- lib/lp/code/model/gitrepository.py 2018-08-29 17:11:57 +0000
+++ lib/lp/code/model/gitrepository.py 2018-08-31 11:44:12 +0000
@@ -887,10 +887,15 @@
BranchMergeProposal,
BranchMergeProposal.source_git_repository == self)
- def getPrecachedLandingTargets(self, user):
+ def getPrecachedLandingTargets(self, user, ignore_merged=False):
"""See `IGitRepository`."""
+ results = self.landing_targets
+ if ignore_merged:
+ results = self.landing_targets.find(
+ Not(BranchMergeProposal.queue_status.is_in(
+ BRANCH_MERGE_PROPOSAL_FINAL_STATES)))
loader = partial(BranchMergeProposal.preloadDataForBMPs, user=user)
- return DecoratedResultSet(self.landing_targets, pre_iter_hook=loader)
+ return DecoratedResultSet(results, pre_iter_hook=loader)
@property
def _api_landing_targets(self):
=== modified file 'lib/lp/code/templates/gitrepository-pending-merges.pt'
--- lib/lp/code/templates/gitrepository-pending-merges.pt 2018-08-29 17:11:57 +0000
+++ lib/lp/code/templates/gitrepository-pending-merges.pt 2018-08-31 11:44:12 +0000
@@ -22,8 +22,8 @@
</div>
- <div id="landing-targets" tal:condition="view/landing_targets">
- <tal:landing-candidates repeat="mergeproposal view/landing_targets">
+ <div id="landing-targets" tal:condition="view/active_landing_targets">
+ <tal:landing-candidates repeat="mergeproposal view/active_landing_targets">
<tal:merge-fragment
tal:replace="structure mergeproposal/@@+summary-fragment"/>
</tal:landing-candidates>
Follow ups