Ubuntu Pastebin

Paste from cjwatson at Thu, 30 Apr 2015 23:08:51 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
=== modified file 'lib/lp/code/browser/branchlisting.py'
--- lib/lp/code/browser/branchlisting.py	2015-04-22 12:03:05 +0000
+++ lib/lp/code/browser/branchlisting.py	2015-04-29 15:16:50 +0000
@@ -69,6 +69,7 @@ from lp.blueprints.interfaces.specificat
 from lp.bugs.interfaces.bugbranch import IBugBranchSet
 from lp.code.browser.branch import BranchMirrorMixin
 from lp.code.browser.branchmergeproposallisting import ActiveReviewsView
+from lp.code.browser.gitrepository import GitRefBatchNavigator
 from lp.code.browser.summary import BranchCountSummaryView
 from lp.code.enums import (
     BranchLifecycleStatus,
@@ -85,6 +86,8 @@ from lp.code.interfaces.branch import (
 from lp.code.interfaces.branchcollection import IAllBranches
 from lp.code.interfaces.branchnamespace import IBranchNamespacePolicy
 from lp.code.interfaces.branchtarget import IBranchTarget
+from lp.code.interfaces.gitcollection import IAllGitRepositories
+from lp.code.interfaces.gitrepository import IGitRepositorySet
 from lp.code.interfaces.revision import IRevisionSet
 from lp.code.interfaces.revisioncache import IRevisionCache
 from lp.code.interfaces.seriessourcepackagebranch import (
@@ -525,6 +528,7 @@ class BranchListingView(LaunchpadFormVie
     field_names = ['lifecycle', 'sort_by']
     development_focus_branch = None
     show_set_development_focus = False
+    default_git_repository = None
     custom_widget('lifecycle', LaunchpadDropdownWidget)
     custom_widget('sort_by', LaunchpadDropdownWidget)
     # Showing the series links is only really useful on product listing
@@ -602,12 +606,22 @@ class BranchListingView(LaunchpadFormVie
         """Override this to say what branches will be in the listing."""
         raise NotImplementedError(self._getCollection)
 
+    def _getGitCollection(self):
+        """Override this to say what Git repositories will be in the
+        listing."""
+        raise NotImplementedError(self._getGitCollection)
+
     @cachedproperty
     def branch_count(self):
         """The number of total branches the user can see."""
         return self._getCollection().visibleByUser(self.user).count()
 
     @cachedproperty
+    def git_repository_count(self):
+        """The number of total Git repositories the user can see."""
+        return self._getGitCollection().visibleByUser(self.user).count()
+
+    @cachedproperty
     def is_branch_count_zero(self):
         """Is the number of total branches the user can see zero?."""
         # If the batch itself is not empty, we don't need to check
@@ -1086,6 +1100,9 @@ class ProductBranchListingView(BranchLis
     def _getCollection(self):
         return getUtility(IAllBranches).inProduct(self.context)
 
+    def _getGitCollection(self):
+        return getUtility(IAllGitRepositories).inProject(self.context)
+
     @cachedproperty
     def development_focus_branch(self):
         dev_focus_branch = self.context.development_focus.branch
@@ -1096,6 +1113,21 @@ class ProductBranchListingView(BranchLis
         else:
             return None
 
+    @cachedproperty
+    def default_git_repository(self):
+        repository = getUtility(IGitRepositorySet).getDefaultRepository(
+            self.context)
+        if repository is None:
+            return None
+        elif check_permission('launchpad.View', repository):
+            return repository
+        else:
+            return None
+
+    def default_git_repository_branches(self):
+        """All branches in the default Git repository, sorted for display."""
+        return GitRefBatchNavigator(self, self.default_git_repository)
+
     @property
     def no_branch_message(self):
         if (self.selected_lifecycle_status is not None
@@ -1179,17 +1211,37 @@ class ProductCodeIndexView(ProductBranch
             product=self.context))
 
     @cachedproperty
-    def person_owner_count(self):
+    def branch_person_owner_count(self):
         """The number of individual people who own branches."""
         return len([person for person in self._branch_owners
                     if not person.is_team])
 
     @cachedproperty
-    def team_owner_count(self):
+    def branch_team_owner_count(self):
         """The number of teams who own branches."""
         return len([person for person in self._branch_owners
                     if person.is_team])
 
+    @cachedproperty
+    def _git_repository_owners(self):
+        """The owners of Git repositories."""
+        # Listify the owners, there really shouldn't be that many for any
+        # one project.
+        return list(getUtility(IPersonSet).getPeopleWithGitRepositories(
+            product=self.context))
+
+    @cachedproperty
+    def git_repository_person_owner_count(self):
+        """The number of individual people who own Git repositories."""
+        return len([person for person in self._git_repository_owners
+                    if not person.is_team])
+
+    @cachedproperty
+    def git_repository_team_owner_count(self):
+        """The number of teams who own Git repositories."""
+        return len([person for person in self._git_repository_owners
+                    if person.is_team])
+
     def _getSeriesBranches(self):
         """Get the series branches for the product, dev focus first."""
         # We want to show each series branch only once, always show the
@@ -1261,17 +1313,39 @@ class ProductCodeIndexView(ProductBranch
         return self.development_focus_branch is not None
 
     @property
+    def has_default_git_repository(self):
+        """Is there a default Git repository?"""
+        return self.default_git_repository is not None
+
+    @property
     def branch_text(self):
         return get_plural_text(self.branch_count, _('branch'), _('branches'))
 
     @property
-    def person_text(self):
+    def branch_person_text(self):
+        return get_plural_text(
+            self.branch_person_owner_count, _('person'), _('people'))
+
+    @property
+    def branch_team_text(self):
+        return get_plural_text(
+            self.branch_team_owner_count, _('team'), _('teams'))
+
+    @property
+    def git_repository_text(self):
         return get_plural_text(
-            self.person_owner_count, _('person'), _('people'))
+            self.git_repository_count,
+            _('Git repositories'), _('Git repositories'))
 
     @property
-    def team_text(self):
-        return get_plural_text(self.team_owner_count, _('team'), _('teams'))
+    def git_repository_person_text(self):
+        return get_plural_text(
+            self.git_repository_person_owner_count, _('person'), _('people'))
+
+    @property
+    def git_repository_team_text(self):
+        return get_plural_text(
+            self.git_repository_team_owner_count, _('team'), _('teams'))
 
     @property
     def commit_text(self):

=== modified file 'lib/lp/code/browser/gitrepository.py'
--- lib/lp/code/browser/gitrepository.py	2015-04-21 09:31:58 +0000
+++ lib/lp/code/browser/gitrepository.py	2015-04-29 15:16:31 +0000
@@ -13,7 +13,6 @@ __all__ = [
     'GitRepositoryView',
     ]
 
-from bzrlib import urlutils
 from zope.interface import implements
 
 from lp.app.browser.informationtype import InformationTypePortletMixin
@@ -106,7 +105,7 @@ class GitRepositoryContextMenu(ContextMe
     def source(self):
         """Return a link to the branch's browsing interface."""
         text = "Browse the code"
-        url = self.context.getCodebrowseUrl()
+        url = self.context.browse_source_url
         return Link(url, text, icon="info")
 
 
@@ -151,22 +150,6 @@ class GitRepositoryView(InformationTypeP
                 self.request, "launchpad.LimitedView", authorised_people)
 
     @property
-    def anon_url(self):
-        if self.context.visibleByUser(None):
-            return urlutils.join(
-                config.codehosting.git_anon_root, self.context.shortened_path)
-        else:
-            return None
-
-    @property
-    def ssh_url(self):
-        if self.user is not None:
-            return urlutils.join(
-                config.codehosting.git_ssh_root, self.context.shortened_path)
-        else:
-            return None
-
-    @property
     def user_can_push(self):
         """Whether the user can push to this branch."""
         return check_permission("launchpad.Edit", self.context)

=== modified file 'lib/lp/code/browser/summary.py'
--- lib/lp/code/browser/summary.py	2012-01-01 02:58:52 +0000
+++ lib/lp/code/browser/summary.py	2015-03-24 12:19:10 +0000
@@ -12,6 +12,7 @@ __all__ = [
 from lp import _
 from lp.code.interfaces.branch import DEFAULT_BRANCH_STATUS_IN_LISTING
 from lp.code.interfaces.branchcollection import IBranchCollection
+from lp.code.interfaces.gitcollection import IGitCollection
 from lp.code.interfaces.revisioncache import IRevisionCache
 from lp.services.browser_helpers import get_plural_text
 from lp.services.propertycache import cachedproperty
@@ -22,42 +23,67 @@ class BranchCountSummaryView(LaunchpadVi
     """A view to give a summary of interesting counts."""
 
     @cachedproperty
-    def _collection(self):
-        """Return the branch collection for this context."""
+    def _branch_collection(self):
+        """Return the Bazaar branch collection for this context."""
         collection = IBranchCollection(self.context).visibleByUser(self.user)
         collection = collection.withLifecycleStatus(
             *DEFAULT_BRANCH_STATUS_IN_LISTING)
         return collection
 
     @cachedproperty
+    def _git_collection(self):
+        """Return the Git repository collection for this context."""
+        return IGitCollection(self.context).visibleByUser(self.user)
+
+    @cachedproperty
     def _revision_cache(self):
         """Return the revision cache for this context."""
         return IRevisionCache(self.context)
 
     @cachedproperty
     def branch_count(self):
-        """The number of total branches the user can see."""
-        return self._collection.count()
+        """The number of total Bazaar branches the user can see."""
+        return self._branch_collection.count()
 
     @cachedproperty
     def branch_owners(self):
-        """The number of individuals and teams that own branches."""
-        return self._collection.ownerCounts()
+        """The number of individuals and teams that own Bazaar branches."""
+        return self._branch_collection.ownerCounts()
+
+    @cachedproperty
+    def git_repository_count(self):
+        """The number of total Git repositories the user can see."""
+        return self._git_collection.count()
+
+    @cachedproperty
+    def git_repository_owners(self):
+        """The number of individuals and teams that own Git repositories."""
+        return self._git_collection.ownerCounts()
 
     @property
-    def person_owner_count(self):
+    def branch_person_owner_count(self):
         return self.branch_owners[0]
 
     @property
-    def team_owner_count(self):
+    def branch_team_owner_count(self):
         return self.branch_owners[1]
 
+    @property
+    def git_repository_person_owner_count(self):
+        return self.git_repository_owners[0]
+
+    @property
+    def git_repository_team_owner_count(self):
+        return self.git_repository_owners[1]
+
     @cachedproperty
     def commit_count(self):
+        # XXX cjwatson 2015-03-23: include Git repositories?
         return self._revision_cache.count()
 
     @cachedproperty
     def committer_count(self):
+        # XXX cjwatson 2015-03-23: include Git repositories?
         return self._revision_cache.authorCount()
 
     @property
@@ -66,13 +92,30 @@ class BranchCountSummaryView(LaunchpadVi
             self.branch_count, _('active branch'), _('active branches'))
 
     @property
-    def person_text(self):
+    def branch_person_text(self):
         return get_plural_text(
-            self.person_owner_count, _('person'), _('people'))
+            self.branch_person_owner_count, _('person'), _('people'))
 
     @property
-    def team_text(self):
-        return get_plural_text(self.team_owner_count, _('team'), _('teams'))
+    def branch_team_text(self):
+        return get_plural_text(
+            self.branch_team_owner_count, _('team'), _('teams'))
+
+    @property
+    def git_repository_text(self):
+        return get_plural_text(
+            self.git_repository_count,
+            _('Git repository'), _('Git repositories'))
+
+    @property
+    def git_repository_person_text(self):
+        return get_plural_text(
+            self.git_repository_person_owner_count, _('person'), _('people'))
+
+    @property
+    def git_repository_team_text(self):
+        return get_plural_text(
+            self.git_repository_team_owner_count, _('team'), _('teams'))
 
     @property
     def commit_text(self):

=== modified file 'lib/lp/code/interfaces/gitrepository.py'
--- lib/lp/code/interfaces/gitrepository.py	2015-04-28 16:39:15 +0000
+++ lib/lp/code/interfaces/gitrepository.py	2015-04-29 15:17:22 +0000
@@ -217,6 +217,14 @@ class IGitRepositoryView(Interface):
         "The identity of this repository: a VCS-independent synonym for "
         "git_identity.")
 
+    browse_source_url = Attribute("A browsing URL for this Git repository.")
+
+    anon_url = Attribute(
+        "An anonymous (git://) URL for this repository, or None in the case "
+        "of private repositories.")
+
+    ssh_url = Attribute("A git+ssh:// URL for this repository.")
+
     refs = exported(CollectionField(
         title=_("The references present in this repository."),
         readonly=True,
@@ -320,9 +328,6 @@ class IGitRepositoryView(Interface):
             otherwise False.
         """
 
-    def getCodebrowseUrl():
-        """Construct a browsing URL for this Git repository."""
-
     def visibleByUser(user):
         """Can the specified user see this repository?"""
 

=== modified file 'lib/lp/code/model/gitrepository.py'
--- lib/lp/code/model/gitrepository.py	2015-04-28 16:39:15 +0000
+++ lib/lp/code/model/gitrepository.py	2015-04-29 15:16:31 +0000
@@ -316,12 +316,28 @@ class GitRepository(StormBase, GitIdenti
         # See also `IGitLookup.getByHostingPath`.
         return str(self.id)
 
-    def getCodebrowseUrl(self):
+    @property
+    def browse_source_url(self):
         """See `IGitRepository`."""
         return urlutils.join(
             config.codehosting.git_browse_root, self.unique_name)
 
     @property
+    def anon_url(self):
+        """See `IGitRepository`."""
+        if self.visibleByUser(None):
+            return urlutils.join(
+                config.codehosting.git_anon_root, self.shortened_path)
+        else:
+            return None
+
+    @property
+    def ssh_url(self):
+        """See `IGitRepository`."""
+        return urlutils.join(
+            config.codehosting.git_ssh_root, self.shortened_path)
+
+    @property
     def private(self):
         return self.information_type in PRIVATE_INFORMATION_TYPES
 

=== modified file 'lib/lp/code/model/tests/test_gitcollection.py'
--- lib/lp/code/model/tests/test_gitcollection.py	2015-04-22 16:42:57 +0000
+++ lib/lp/code/model/tests/test_gitcollection.py	2015-04-29 15:16:31 +0000
@@ -842,7 +842,7 @@ class TestSearch(TestCaseWithFactory):
         # repository.
         repository = self.factory.makeGitRepository()
         self.factory.makeGitRepository()
-        search_results = self.collection.search(repository.getCodebrowseUrl())
+        search_results = self.collection.search(repository.browse_source_url)
         self.assertEqual([repository], list(search_results))
 
     def test_exact_match_with_lp_colon_url(self):
@@ -905,7 +905,7 @@ class TestSearch(TestCaseWithFactory):
         repository = self.factory.makeGitRepository()
         self.factory.makeGitRepository()
         search_results = self.collection.search(
-            repository.getCodebrowseUrl() + '/')
+            repository.browse_source_url + '/')
         self.assertEqual([repository], list(search_results))
 
     def test_match_exact_repository_name(self):

=== modified file 'lib/lp/code/model/tests/test_gitrepository.py'
--- lib/lp/code/model/tests/test_gitrepository.py	2015-04-28 16:39:15 +0000
+++ lib/lp/code/model/tests/test_gitrepository.py	2015-04-29 15:16:31 +0000
@@ -367,7 +367,7 @@ class TestCodebrowse(TestCaseWithFactory
         repository = self.factory.makeGitRepository()
         self.assertEqual(
             "https://git.launchpad.dev/" + repository.unique_name,
-            repository.getCodebrowseUrl())
+            repository.browse_source_url)
 
 
 class TestGitRepositoryNamespace(TestCaseWithFactory):

=== modified file 'lib/lp/code/templates/branch-count-summary.pt'
--- lib/lp/code/templates/branch-count-summary.pt	2009-09-08 08:48:35 +0000
+++ lib/lp/code/templates/branch-count-summary.pt	2015-03-24 12:19:10 +0000
@@ -13,16 +13,16 @@
   <tal:branches replace="view/branch_text">branches</tal:branches
   ><tal:has-branches condition="view/branch_count">
   owned by
-  <tal:individuals condition="view/person_owner_count">
-    <strong tal:content="view/person_owner_count">42</strong>
-    <tal:people replace="view/person_text">people</tal:people
+  <tal:individuals condition="view/branch_person_owner_count">
+    <strong tal:content="view/branch_person_owner_count">42</strong>
+    <tal:people replace="view/branch_person_text">people</tal:people
     ></tal:individuals
-    ><tal:teams condition="view/team_owner_count">
-    <tal:individuals condition="view/person_owner_count">
+    ><tal:teams condition="view/branch_team_owner_count">
+    <tal:individuals condition="view/branch_person_owner_count">
       and
     </tal:individuals>
-    <strong tal:content="view/team_owner_count">1</strong>
-    <tal:people replace="view/team_text">team</tal:people
+    <strong tal:content="view/branch_team_owner_count">1</strong>
+    <tal:people replace="view/branch_team_text">team</tal:people
     ></tal:teams></tal:has-branches>,
 
     <strong tal:content="view/commit_count">23</strong>

=== modified file 'lib/lp/code/templates/gitrepository-management.pt'
--- lib/lp/code/templates/gitrepository-management.pt	2015-03-04 16:49:42 +0000
+++ lib/lp/code/templates/gitrepository-management.pt	2015-03-24 12:19:10 +0000
@@ -7,15 +7,15 @@
   <dl id="clone-url">
     <dt>Get this repository:</dt>
     <dd>
-      <tal:anonymous condition="view/anon_url">
+      <tal:anonymous condition="context/anon_url">
         <tt class="command">
-          git clone <span class="anon-url" tal:content="view/anon_url" />
+          git clone <span class="anon-url" tal:content="context/anon_url" />
         </tt>
         <br />
       </tal:anonymous>
-      <tal:ssh condition="view/ssh_url">
+      <tal:ssh condition="view/user">
         <tt class="command">
-          git clone <span class="ssh-url" tal:content="view/ssh_url" />
+          git clone <span class="ssh-url" tal:content="context/ssh_url" />
         </tt>
       </tal:ssh>
     </dd>

=== modified file 'lib/lp/code/templates/product-branch-summary.pt'
--- lib/lp/code/templates/product-branch-summary.pt	2012-10-08 02:02:19 +0000
+++ lib/lp/code/templates/product-branch-summary.pt	2015-03-24 12:19:10 +0000
@@ -56,7 +56,8 @@
     </p>
   </div>
 
-  <tal:no-branches condition="not: view/branch_count">
+  <tal:no-branches
+      condition="python: not view.branch_count and not view.git_repository_count">
     There are no branches for <tal:project-name replace="context/displayname"/>
     in Launchpad.
     <tal:can-configure condition="view/can_configure_branches">
@@ -78,6 +79,25 @@
     </tal:can-configure>
   </tal:no-branches>
 
+  <tal:has-git condition="view/git_repository_count">
+    <div tal:condition="view/has_default_git_repository"
+         style="margin: 1em 0"
+         tal:define="repository view/default_git_repository">
+      You can
+      <a tal:attributes="href repository/browse_source_url">browse the
+        source code</a>
+      for the default Git repository or get a copy of the repository using
+      the command:<br/>
+      <tt class="command">git clone
+      <tal:logged-in condition="view/user">
+        <tal:git-ssh-url replace="repository/ssh_url"/>
+      </tal:logged-in>
+      <tal:not-logged-in condition="not: view/user">
+        <tal:git-anon-url replace="repository/anon_url"/>
+      </tal:not-logged-in>
+    </div>
+  </tal:has-git>
+
   <tal:has-branches condition="view/branch_count">
     <div tal:condition="view/has_development_focus_branch"
          style="margin: 1em 0"
@@ -94,23 +114,23 @@
        using the command:<br/>
       <tt class="command">bzr branch <tal:project-name replace="dev_focus/bzr_identity"/></tt>
     </div>
-  </tal:has-branches>
 
-  <tal:has-user condition="view/user">
-    <p id="push-instructions"
-      tal:condition="not: context/codehosting_usage/enumvalue:UNKNOWN">
-      You can push the branch directly to Launchpad with the command:<br />
-      <tt class="command">
-        bzr push lp:~<tal:user replace="view/user/name"/>/<tal:project replace="context/name"/>/<tal:series replace="context/name"/>
-      </tt>
-      <tal:no-keys condition="not:view/user/sshkeys">
-        <br/>To authenticate with the Launchpad branch upload service,
-        you need to
-        <a tal:attributes="href string:${view/user/fmt:url}/+editsshkeys">
-          register a SSH key</a>.
-      </tal:no-keys>
-    </p>
-  </tal:has-user>
+    <tal:has-user condition="view/user">
+      <p id="push-instructions"
+        tal:condition="not: context/codehosting_usage/enumvalue:UNKNOWN">
+        You can push the branch directly to Launchpad with the command:<br />
+        <tt class="command">
+          bzr push lp:~<tal:user replace="view/user/name"/>/<tal:project replace="context/name"/>/<tal:series replace="context/name"/>
+        </tt>
+        <tal:no-keys condition="not:view/user/sshkeys">
+          <br/>To authenticate with Launchpad so that you can push code,
+          you need to
+          <a tal:attributes="href string:${view/user/fmt:url}/+editsshkeys">
+            register a SSH key</a>.
+        </tal:no-keys>
+      </p>
+    </tal:has-user>
+  </tal:has-branches>
 
   <div tal:condition="context/codehosting_usage/enumvalue:UNKNOWN">
     <div

=== modified file 'lib/lp/code/templates/product-branches.pt'
--- lib/lp/code/templates/product-branches.pt	2012-10-08 02:02:19 +0000
+++ lib/lp/code/templates/product-branches.pt	2015-03-24 12:19:10 +0000
@@ -60,6 +60,13 @@
       condition="not: view/context/codehosting_usage/enumvalue:UNKNOWN"
       replace="structure context/@@+portlet-product-codestatistics" />
 
+    <tal:has-default-git-repository condition="view/has_default_git_repository">
+      <div id="default-repository-branches"
+           tal:define="branches view/default_git_repository_branches">
+        <tal:default-repository-branches replace="structure branches/@@+ref-listing" />
+      </div>
+    </tal:has-default-git-repository>
+
     <tal:has-branches condition="view/branch_count"
                       define="branches view/branches">
       <tal:branchlisting content="structure branches/@@+branch-listing" />

=== modified file 'lib/lp/code/templates/product-portlet-codestatistics.pt'
--- lib/lp/code/templates/product-portlet-codestatistics.pt	2011-09-16 14:18:11 +0000
+++ lib/lp/code/templates/product-portlet-codestatistics.pt	2015-03-24 12:19:10 +0000
@@ -13,6 +13,34 @@
       <tal:link replace="structure python: link.render().lower()"/>.
     </p>
 
+    <!--Git repositories-->
+    <p>
+    <tal:comment condition="nothing">
+      The bad breaks in the following block are to force the period to be
+      in the right place.
+    </tal:comment>
+    <span tal:define="count view/git_repository_count;"
+          id="git-repository-count-summary">
+      <tal:project replace="context/displayname"/> has
+      <tal:git-repository-count replace="count"/>
+      <tal:git-repositories replace="view/git_repository_text">
+        Git repositories
+      </tal:git-repositories
+      ><tal:has-git-repositories condition="view/git_repository_count">
+        owned by
+        <tal:individuals condition="view/git_repository_person_owner_count">
+          <tal:owners content="view/git_repository_person_owner_count">42</tal:owners>
+          <tal:people replace="view/git_repository_person_text">people</tal:people
+        ></tal:individuals
+        ><tal:teams condition="view/git_repository_team_owner_count">
+          <tal:individuals condition="view/git_repository_person_owner_count">
+            and
+          </tal:individuals
+          ><tal:toc content="view/git_repository_team_owner_count">1</tal:toc>
+          <tal:people replace="view/git_repository_team_text">team</tal:people
+          ></tal:teams></tal:has-git-repositories>.
+    </span>
+
     <!--branches-->
     <p>
     <tal:comment condition="nothing">
@@ -28,16 +56,16 @@
       </tal:branches
       ><tal:has-branches condition="view/branch_count">
         owned by
-        <tal:individuals condition="view/person_owner_count">
-          <tal:owners content="view/person_owner_count">42</tal:owners>
-          <tal:people replace="view/person_text">people</tal:people
+        <tal:individuals condition="view/branch_person_owner_count">
+          <tal:owners content="view/branch_person_owner_count">42</tal:owners>
+          <tal:people replace="view/branch_person_text">people</tal:people
         ></tal:individuals
-        ><tal:teams condition="view/team_owner_count">
-          <tal:individuals condition="view/person_owner_count">
+        ><tal:teams condition="view/branch_team_owner_count">
+          <tal:individuals condition="view/branch_person_owner_count">
             and
           </tal:individuals
-          ><tal:toc content="view/team_owner_count">1</tal:toc>
-          <tal:people replace="view/team_text">team</tal:people
+          ><tal:toc content="view/branch_team_owner_count">1</tal:toc>
+          <tal:people replace="view/branch_team_text">team</tal:people
           ></tal:teams></tal:has-branches>.
     </span>
 

=== modified file 'lib/lp/registry/interfaces/person.py'
--- lib/lp/registry/interfaces/person.py	2015-04-28 15:54:00 +0000
+++ lib/lp/registry/interfaces/person.py	2015-04-29 15:16:31 +0000
@@ -2377,6 +2377,13 @@ class IPersonSet(Interface):
             specified product are returned.
         """
 
+    def getPeopleWithGitRepositories(product=None):
+        """Return the people who have Git repositories.
+
+        :param product: If supplied, only people who have Git repositories
+            in the specified product are returned.
+        """
+
     def updatePersonalStandings():
         """Update the personal standings of some people.
 

=== modified file 'lib/lp/registry/model/person.py'
--- lib/lp/registry/model/person.py	2015-04-19 12:56:32 +0000
+++ lib/lp/registry/model/person.py	2015-04-29 15:16:31 +0000
@@ -3777,6 +3777,15 @@ class PersonSet:
             Person.id in (%s)
             ''' % branch_clause)
 
+    def getPeopleWithGitRepositories(self, product=None):
+        """See `IPersonSet`."""
+        repository_clause = 'SELECT owner FROM GitRepository'
+        if product is not None:
+            repository_clause += ' WHERE product = %s' % quote(product)
+        return Person.select('''
+            Person.id in (%s)
+            ''' % repository_clause)
+
     def updatePersonalStandings(self):
         """See `IPersonSet`."""
         cur = cursor()

=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py	2015-03-17 10:45:07 +0000
+++ lib/lp/registry/model/product.py	2015-03-24 12:19:10 +0000
@@ -116,6 +116,7 @@ from lp.bugs.model.structuralsubscriptio
     )
 from lp.code.enums import BranchType
 from lp.code.interfaces.branch import DEFAULT_BRANCH_STATUS_IN_LISTING
+from lp.code.interfaces.gitrepository import IGitRepositorySet
 from lp.code.model.branch import Branch
 from lp.code.model.branchnamespace import BRANCH_POLICY_ALLOWED_TYPES
 from lp.code.model.hasbranches import (
@@ -581,7 +582,10 @@ class Product(SQLBase, BugTargetBase, Ma
 
     @property
     def official_codehosting(self):
-        return self.development_focus.branch is not None
+        repository = getUtility(IGitRepositorySet).getDefaultRepository(self)
+        return (
+            self.development_focus.branch is not None or
+            repository is not None)
 
     @property
     def official_anything(self):
@@ -613,9 +617,11 @@ class Product(SQLBase, BugTargetBase, Ma
 
     @property
     def codehosting_usage(self):
-        if self.development_focus.branch is None:
+        repository = getUtility(IGitRepositorySet).getDefaultRepository(self)
+        if self.development_focus.branch is None and repository is None:
             return ServiceUsage.UNKNOWN
-        elif self.development_focus.branch.branch_type == BranchType.HOSTED:
+        elif (repository is not None or
+              self.development_focus.branch.branch_type == BranchType.HOSTED):
             return ServiceUsage.LAUNCHPAD
         elif self.development_focus.branch.branch_type in (
             BranchType.MIRRORED,
Download as text