launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #23507
[Merge] lp:~twom/launchpad/add-rescan-link-to-merge-proposals into lp:launchpad
Tom Wardill has proposed merging lp:~twom/launchpad/add-rescan-link-to-merge-proposals into lp:launchpad.
Commit message:
Add a rescan button to branch merge proposals for failed branch or repository scans
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~twom/launchpad/add-rescan-link-to-merge-proposals/+merge/366060
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~twom/launchpad/add-rescan-link-to-merge-proposals into lp:launchpad.
=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
--- lib/lp/code/browser/branchmergeproposal.py 2019-01-31 14:45:32 +0000
+++ lib/lp/code/browser/branchmergeproposal.py 2019-04-15 14:54:12 +0000
@@ -807,6 +807,16 @@
return False
return latest_preview.job.status == JobStatus.FAILED
+ def get_rescan_links(self):
+ repos = []
+ source_job = self.context.parent.getLatestScanJob()
+ target_job = self.context.target_branch_or_repo.getLatestScanJob()
+ if source_job and source_job.job.status == JobStatus.FAILED:
+ repos.append(self.context.parent)
+ if target_job and target_job.job.status == JobStatus.FAILED:
+ repos.append(self.context.target_branch_or_repo)
+ return repos
+
@delegate_to(ICodeReviewVoteReference)
class DecoratedCodeReviewVoteReference:
=== modified file 'lib/lp/code/browser/gitrepository.py'
--- lib/lp/code/browser/gitrepository.py 2019-04-01 10:09:31 +0000
+++ lib/lp/code/browser/gitrepository.py 2019-04-15 14:54:12 +0000
@@ -463,7 +463,9 @@
def rescan(self, action, data):
self.context.rescan()
self.request.response.addNotification("Repository scan scheduled")
- self.next_url = canonical_url(self.context)
+ # This can be used by BMP, in which case we want to redirect back
+ # from whence it came.
+ self.next_url = self.request.headers.get('referer')
class GitRepositoryEditFormView(LaunchpadEditFormView):
=== modified file 'lib/lp/code/browser/tests/test_branchmergeproposal.py'
--- lib/lp/code/browser/tests/test_branchmergeproposal.py 2019-01-31 14:21:09 +0000
+++ lib/lp/code/browser/tests/test_branchmergeproposal.py 2019-04-15 14:54:12 +0000
@@ -51,6 +51,7 @@
from zope.security.proxy import removeSecurityProxy
from lp.app.enums import InformationType
+from lp.code.model.branchjob import BranchScanJob
from lp.code.browser.branch import RegisterBranchMergeProposalView
from lp.code.browser.branchmergeproposal import (
BranchMergeProposalAddVoteView,
@@ -76,6 +77,7 @@
)
from lp.code.model.branchmergeproposaljob import UpdatePreviewDiffJob
from lp.code.model.diff import PreviewDiff
+from lp.code.model.gitjob import GitRefScanJob
from lp.code.tests.helpers import (
add_revision_to_branch,
GitHostingFixture,
@@ -2177,6 +2179,33 @@
result = view.show_diff_update_link
self.assertTrue(result)
+ def test_get_rescan_links_git(self):
+ bmp = self.factory.makeBranchMergeProposalForGit()
+ target_job = GitRefScanJob.create(bmp.target_git_repository)
+ target_job.job._status = JobStatus.FAILED
+ view = create_initialized_view(bmp, '+index')
+ result = view.get_rescan_links()
+ self.assertEqual([bmp.target_git_repository], result)
+
+ def test_get_rescan_links_bzr(self):
+ bmp = self.factory.makeBranchMergeProposal()
+ target_job = BranchScanJob.create(bmp.target_branch)
+ target_job.job._status = JobStatus.FAILED
+ view = create_initialized_view(bmp, '+index')
+ result = view.get_rescan_links()
+ self.assertEqual([bmp.target_branch], result)
+
+ def test_get_rescan_links_both_failed(self):
+ bmp = self.factory.makeBranchMergeProposalForGit()
+ target_job = GitRefScanJob.create(bmp.target_git_repository)
+ target_job.job._status = JobStatus.FAILED
+ source_job = GitRefScanJob.create(bmp.source_git_repository)
+ source_job.job._status = JobStatus.FAILED
+ view = create_initialized_view(bmp, '+index')
+ result = view.get_rescan_links()
+ self.assertEqual(
+ [bmp.source_git_repository, bmp.target_git_repository], result)
+
class TestLatestProposalsForEachBranchMixin:
"""Confirm that the latest branch is returned."""
=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
--- lib/lp/code/interfaces/branchmergeproposal.py 2019-01-31 11:33:58 +0000
+++ lib/lp/code/interfaces/branchmergeproposal.py 2019-04-15 14:54:12 +0000
@@ -222,6 +222,9 @@
"The parent object for use in navigation: source branch for Bazaar, "
"or source repository for Git.")
+ target_branch_or_repo = Attribute(
+ "The target source control branch (bzr) or repository (git)")
+
class IBranchMergeProposalView(Interface):
=== modified file 'lib/lp/code/model/branchmergeproposal.py'
--- lib/lp/code/model/branchmergeproposal.py 2019-02-01 14:08:34 +0000
+++ lib/lp/code/model/branchmergeproposal.py 2019-04-15 14:54:12 +0000
@@ -315,6 +315,13 @@
else:
return self.source_git_repository
+ @property
+ def target_branch_or_repo(self):
+ if self.target_branch is not None:
+ return self.target_branch
+ else:
+ return self.target_git_repository
+
description = StringCol(default=None)
whiteboard = StringCol(default=None)
=== modified file 'lib/lp/code/templates/branchmergeproposal-index.pt'
--- lib/lp/code/templates/branchmergeproposal-index.pt 2019-01-31 13:48:34 +0000
+++ lib/lp/code/templates/branchmergeproposal-index.pt 2019-04-15 14:54:12 +0000
@@ -208,6 +208,25 @@
</p>
</div>
</div>
+ <div class="yui-g" tal:repeat="repo view/get_rescan_links">
+ <div class="pending-update" id="diff-pending-update">
+ <span tal:condition="repeat/repo/start">
+ <h3>Update scan failed</h3>
+ <p>
+ At least one of the branches involved have failed to scan.
+ You can manually schedule a rescan if required.
+ </p>
+ </span>
+ <p>
+ <form action="+rescan" tal:attributes="action repo/fmt:url/+rescan"
+ name="launchpadform" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
+ <input id="field.actions.rescan" class="button" type="submit"
+ name="field.actions.rescan" value="Rescan" />
+ <span tal:content="structure repo/fmt:link/+rescan" />
+ </form>
+ </p>
+ </div>
+ </div>
<div id="review-diff" tal:condition="view/preview_diff">
<h2>Preview Diff </h2>
Follow ups