launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24824
[Merge] ~pappacena/launchpad:gitrepo-status into launchpad:master
Thiago F. Pappacena has proposed merging ~pappacena/launchpad:gitrepo-status into launchpad:master.
Commit message:
Adding "status" attribute to GitRepository, with the options "available" and "creating".
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/385208
This MP depends on the database patchs https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/385199 and https://code.launchpad.net/~pappacena/launchpad/+git/launchpad/+merge/385198.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~pappacena/launchpad:gitrepo-status into launchpad:master.
diff --git a/lib/lp/code/enums.py b/lib/lp/code/enums.py
index c472c6a..8a09a72 100644
--- a/lib/lp/code/enums.py
+++ b/lib/lp/code/enums.py
@@ -26,6 +26,7 @@ __all__ = [
'GitListingSort',
'GitObjectType',
'GitPermissionType',
+ 'GitRepositoryStatus',
'GitRepositoryType',
'NON_CVS_RCS_TYPES',
'RevisionControlSystems',
@@ -148,6 +149,25 @@ class GitRepositoryType(DBEnumeratedType):
""")
+class GitRepositoryStatus(DBEnumeratedType):
+ """Git Repository Status
+
+ The current situation of this Git Repository.
+ """
+
+ AVAILABLE = DBItem(1, """
+ Available
+
+ This repository is available to be used.
+ """)
+
+ CREATING = DBItem(2, """
+ Creating
+
+ This repository is being created on git hosting system.
+ """)
+
+
class GitObjectType(DBEnumeratedType):
"""Git Object Type
diff --git a/lib/lp/code/interfaces/gitrepository.py b/lib/lp/code/interfaces/gitrepository.py
index 3f636cc..b2cbaae 100644
--- a/lib/lp/code/interfaces/gitrepository.py
+++ b/lib/lp/code/interfaces/gitrepository.py
@@ -66,6 +66,7 @@ from lp.code.enums import (
BranchSubscriptionNotificationLevel,
CodeReviewNotificationLevel,
GitListingSort,
+ GitRepositoryStatus,
GitRepositoryType,
)
from lp.code.interfaces.defaultgit import ICanHasDefaultGitRepository
@@ -143,6 +144,11 @@ class IGitRepositoryView(IHasRecipes):
"The way this repository is hosted: directly on Launchpad, or "
"imported from somewhere else.")))
+ status = Choice(
+ title=_("Status of this repository"),
+ required=True, readonly=True,
+ vocabulary=GitRepositoryStatus)
+
registrant = exported(PublicPersonChoice(
title=_("Registrant"), required=True, readonly=True,
vocabulary="ValidPersonOrTeam",
diff --git a/lib/lp/code/model/gitrepository.py b/lib/lp/code/model/gitrepository.py
index 2e9080f..0421884 100644
--- a/lib/lp/code/model/gitrepository.py
+++ b/lib/lp/code/model/gitrepository.py
@@ -95,6 +95,7 @@ from lp.code.enums import (
GitListingSort,
GitObjectType,
GitPermissionType,
+ GitRepositoryStatus,
GitRepositoryType,
)
from lp.code.errors import (
@@ -294,6 +295,9 @@ class GitRepository(StormBase, WebhookTargetMixin, GitIdentityMixin):
repository_type = EnumCol(
dbName='repository_type', enum=GitRepositoryType, notNull=True)
+ status = EnumCol(
+ dbName='status', enum=GitRepositoryStatus, notNull=True)
+
registrant_id = Int(name='registrant', allow_none=False)
registrant = Reference(registrant_id, 'Person.id')
@@ -327,7 +331,7 @@ class GitRepository(StormBase, WebhookTargetMixin, GitIdentityMixin):
def __init__(self, repository_type, registrant, owner, target, name,
information_type, date_created, reviewer=None,
- description=None):
+ description=None, status=None):
super(GitRepository, self).__init__()
self.repository_type = repository_type
self.registrant = registrant
@@ -351,6 +355,8 @@ class GitRepository(StormBase, WebhookTargetMixin, GitIdentityMixin):
assert IDistribution.providedBy(target.pillar)
self.ociprojectname = target.ociprojectname
self.distribution = target.pillar
+ self.status = (status if status is not None
+ else GitRepositoryStatus.AVAILABLE)
self.owner_default = False
self.target_default = False
diff --git a/lib/lp/code/model/tests/test_gitrepository.py b/lib/lp/code/model/tests/test_gitrepository.py
index 84044df..aeb1690 100644
--- a/lib/lp/code/model/tests/test_gitrepository.py
+++ b/lib/lp/code/model/tests/test_gitrepository.py
@@ -44,7 +44,10 @@ from testtools.matchers import (
import transaction
from zope.component import getUtility
from zope.publisher.xmlrpc import TestRequest
-from zope.security.interfaces import Unauthorized
+from zope.security.interfaces import (
+ ForbiddenAttribute,
+ Unauthorized,
+ )
from zope.security.proxy import removeSecurityProxy
from lp import _
@@ -63,6 +66,7 @@ from lp.code.enums import (
GitGranteeType,
GitListingSort,
GitObjectType,
+ GitRepositoryStatus,
GitRepositoryType,
TargetRevisionControlSystems,
)
@@ -208,6 +212,23 @@ class TestGitRepository(TestCaseWithFactory):
self.factory.makeGitRepository(),
DoesNotSnapshot(large_properties, IGitRepositoryView))
+ def test_git_repository_default_status(self):
+ repository = self.factory.makeGitRepository()
+ store = Store.of(repository)
+
+ self.assertEqual(GitRepositoryStatus.AVAILABLE, repository.status)
+
+ removeSecurityProxy(repository).status = GitRepositoryStatus.CREATING
+ store.flush()
+ self.assertEqual(GitRepositoryStatus.CREATING, repository.status)
+
+ def test_git_repository_status_is_read_only(self):
+ repository = self.factory.makeGitRepository()
+ with person_logged_in(repository.owner):
+ self.assertRaises(
+ ForbiddenAttribute,
+ setattr, repository, 'status', GitRepositoryStatus.CREATING)
+
def test_unique_name_project(self):
project = self.factory.makeProduct()
repository = self.factory.makeGitRepository(target=project)
Follow ups