← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ines-almeida/launchpad:merge-button/force-rescan-repo-after-merge into launchpad:master

 

Ines Almeida has proposed merging ~ines-almeida/launchpad:merge-button/force-rescan-repo-after-merge into launchpad:master.

Commit message:
Force a target repo rescan after a merge is completed

This will prevent Launchpad from getting out of date with the git hosting client when a merge is done via API

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ines-almeida/launchpad/+git/launchpad/+merge/488829

I am working in a change that will lead us to removing `merge()` API with a `request_merge()` API. But in the meantime, this should fix the issue with the current API where Launchpad is out of sync with the repo after a merge
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ines-almeida/launchpad:merge-button/force-rescan-repo-after-merge into launchpad:master.
diff --git a/lib/lp/code/model/branchmergeproposal.py b/lib/lp/code/model/branchmergeproposal.py
index 6bcce43..179ee62 100644
--- a/lib/lp/code/model/branchmergeproposal.py
+++ b/lib/lp/code/model/branchmergeproposal.py
@@ -1077,6 +1077,11 @@ class BranchMergeProposal(StormBase, BugLinkTargetMixin):
                 "Failed to merge the proposal."
             )
 
+        # Schedule a rescan (similarly to what happens when a push is done to
+        # turnip). This will prevent Launchpad from getting out of date with
+        # turnip's repository
+        self.target_git_repository.rescan()
+
         merge_commit = response["merge_commit"]
         previously_merged = response.get("previously_merged", False)
 
diff --git a/lib/lp/code/model/tests/test_branchmergeproposal.py b/lib/lp/code/model/tests/test_branchmergeproposal.py
index 84bb853..abef332 100644
--- a/lib/lp/code/model/tests/test_branchmergeproposal.py
+++ b/lib/lp/code/model/tests/test_branchmergeproposal.py
@@ -4184,6 +4184,8 @@ class TestBranchMergeProposalMerge(TestCaseWithFactory):
                 proposal.queue_status,
             )
 
+        self.assertIsNotNone(proposal.target_git_repository.getLatestScanJob())
+
     def test_cross_repo_merge_success(self):
         # A successful merge request updates the proposal status