launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #21384
[Merge] lp:~cjwatson/launchpad/git-rescan-api into lp:launchpad
Colin Watson has proposed merging lp:~cjwatson/launchpad/git-rescan-api into lp:launchpad.
Commit message:
Add GitRepository.rescan method, useful in cases when a scan crashed.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/git-rescan-api/+merge/316956
--
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/git-rescan-api into lp:launchpad.
=== modified file 'lib/lp/code/interfaces/gitrepository.py'
--- lib/lp/code/interfaces/gitrepository.py 2017-01-09 17:53:16 +0000
+++ lib/lp/code/interfaces/gitrepository.py 2017-02-10 13:19:57 +0000
@@ -691,6 +691,14 @@
def setTarget(target, user):
"""Set the target of the repository."""
+ @export_write_operation()
+ @operation_for_version("devel")
+ def rescan():
+ """Force a rescan of this repository.
+
+ This may be helpful in cases where a previous scan crashed.
+ """
+
@export_read_operation()
@operation_for_version("devel")
def canBeDeleted():
=== modified file 'lib/lp/code/model/gitrepository.py'
--- lib/lp/code/model/gitrepository.py 2016-12-02 13:01:53 +0000
+++ lib/lp/code/model/gitrepository.py 2017-02-10 13:19:57 +0000
@@ -1,4 +1,4 @@
-# Copyright 2015-2016 Canonical Ltd. This software is licensed under the
+# Copyright 2015-2017 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
@@ -92,6 +92,7 @@
IGitCollection,
)
from lp.code.interfaces.githosting import IGitHostingClient
+from lp.code.interfaces.gitjob import IGitRefScanJobSource
from lp.code.interfaces.gitlookup import IGitLookup
from lp.code.interfaces.gitnamespace import (
get_git_namespace,
@@ -685,6 +686,10 @@
if refs_to_remove:
self.removeRefs(refs_to_remove)
+ def rescan(self):
+ """See `IGitRepository`."""
+ getUtility(IGitRefScanJobSource).create(self)
+
@cachedproperty
def _known_viewers(self):
"""A set of known persons able to view this repository.
=== modified file 'lib/lp/code/model/tests/test_gitrepository.py'
--- lib/lp/code/model/tests/test_gitrepository.py 2017-01-09 17:53:16 +0000
+++ lib/lp/code/model/tests/test_gitrepository.py 2017-02-10 13:19:57 +0000
@@ -1813,6 +1813,20 @@
target=commercial_project, user=owner)
+class TestGitRepositoryRescan(TestCaseWithFactory):
+
+ layer = DatabaseFunctionalLayer
+
+ def test_rescan(self):
+ repository = self.factory.makeGitRepository()
+ job_source = getUtility(IGitRefScanJobSource)
+ self.assertEqual([], list(job_source.iterReady()))
+ with person_logged_in(repository.owner):
+ repository.rescan()
+ [job] = list(job_source.iterReady())
+ self.assertEqual(repository, job.repository)
+
+
class TestGitRepositoryUpdateMergeCommitIDs(TestCaseWithFactory):
layer = DatabaseFunctionalLayer
Follow ups