Merge lp:~cjwatson/launchpad/git-repository-container into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 17947
Proposed branch: lp:~cjwatson/launchpad/git-repository-container
Merge into: lp:launchpad
Prerequisite: lp:~cjwatson/launchpad/refactor-launchpad-container
Diff against target: 57 lines (+31/-0)
3 files modified
lib/lp/code/configure.zcml (+4/-0)
lib/lp/code/publisher.py (+10/-0)
lib/lp/registry/doc/launchpad-container.txt (+17/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/git-repository-container
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+287413@code.launchpad.net

Commit message

Add ILaunchpadContainer implementation for Git repositories.

Description of the change

Add ILaunchpadContainer implementation for Git repositories. It's an easy extension, and we're going to want this for caveats.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/configure.zcml'
2--- lib/lp/code/configure.zcml 2016-01-11 19:16:04 +0000
3+++ lib/lp/code/configure.zcml 2016-02-28 19:36:09 +0000
4@@ -816,6 +816,10 @@
5 interface="lp.code.interfaces.gitrepository.IGitRepositoryEdit"
6 set_schema="lp.code.interfaces.gitrepository.IGitRepositoryEditableAttributes" />
7 </class>
8+ <adapter
9+ for="lp.code.interfaces.gitrepository.IGitRepository"
10+ provides="lp.services.webapp.interfaces.ILaunchpadContainer"
11+ factory="lp.code.publisher.LaunchpadGitRepositoryContainer"/>
12 <subscriber
13 for="lp.code.interfaces.gitrepository.IGitRepository zope.lifecycleevent.interfaces.IObjectModifiedEvent"
14 handler="lp.code.model.gitrepository.git_repository_modified"/>
15
16=== modified file 'lib/lp/code/publisher.py'
17--- lib/lp/code/publisher.py 2016-02-28 19:36:09 +0000
18+++ lib/lp/code/publisher.py 2016-02-28 19:36:09 +0000
19@@ -64,3 +64,13 @@
20 self.context.target.context, ILaunchpadContainer)
21 if adapter is not None:
22 yield adapter
23+
24+
25+class LaunchpadGitRepositoryContainer(LaunchpadContainer):
26+
27+ def getParentContainers(self):
28+ """See `ILaunchpadContainer`."""
29+ # A repository is within its target.
30+ adapter = queryAdapter(self.context.target, ILaunchpadContainer)
31+ if adapter is not None:
32+ yield adapter
33
34=== modified file 'lib/lp/registry/doc/launchpad-container.txt'
35--- lib/lp/registry/doc/launchpad-container.txt 2016-02-28 19:36:09 +0000
36+++ lib/lp/registry/doc/launchpad-container.txt 2016-02-28 19:36:09 +0000
37@@ -120,3 +120,20 @@
38 None
39 >>> ILaunchpadContainer(junk).isWithin('/firefox')
40 False
41+
42+
43+== Git repositories ==
44+
45+A Git repository is within its target.
46+
47+ >>> sample_person = getUtility(IPersonSet).getByName('name12')
48+ >>> firefox_git = factory.makeGitRepository(target=firefox)
49+ >>> ILaunchpadContainer(firefox_git).isWithin('/firefox')
50+ True
51+ >>> ILaunchpadContainer(firefox_git).isWithin('/mozilla')
52+ True
53+
54+But it's not within anything other than its target.
55+
56+ >>> ILaunchpadContainer(firefox_git).isWithin('/ubuntu/+source/evolution')
57+ False