← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/git-webservice-urls into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/git-webservice-urls into lp:launchpad.

Commit message:
Export GitRepository.git_https_url and GitRepository.git_ssh_url.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1462288 in Launchpad itself: "Launchpad API should expose read-only and read-write URL of each GitRepository"
  https://bugs.launchpad.net/launchpad/+bug/1462288

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/git-webservice-urls/+merge/262343

Export GitRepository.git_https_url and GitRepository.git_ssh_url.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/git-webservice-urls into lp:launchpad.
=== modified file 'lib/lp/code/interfaces/gitrepository.py'
--- lib/lp/code/interfaces/gitrepository.py	2015-06-13 01:45:19 +0000
+++ lib/lp/code/interfaces/gitrepository.py	2015-06-18 14:17:18 +0000
@@ -213,11 +213,15 @@
         "The identity of this repository: a VCS-independent synonym for "
         "git_identity.")
 
-    git_https_url = Attribute(
-        "An HTTPS URL for this repository, or None in the case of private "
-        "repositories.")
+    git_https_url = exported(TextLine(
+        title=_("HTTPS URL"), readonly=True,
+        description=_(
+            "An HTTPS URL for this repository, or None in the case of private "
+            "repositories.")))
 
-    git_ssh_url = Attribute("A git+ssh:// URL for this repository.")
+    git_ssh_url = exported(TextLine(
+        title=_("SSH URL"), readonly=True,
+        description=_("A git+ssh:// URL for this repository.")))
 
     refs = exported(CollectionField(
         title=_("The references present in this repository."),

=== modified file 'lib/lp/code/model/tests/test_gitrepository.py'
--- lib/lp/code/model/tests/test_gitrepository.py	2015-06-15 09:55:47 +0000
+++ lib/lp/code/model/tests/test_gitrepository.py	2015-06-18 14:17:18 +0000
@@ -2118,6 +2118,24 @@
 
     layer = DatabaseFunctionalLayer
 
+    def test_urls(self):
+        owner_db = self.factory.makePerson(name="person")
+        project_db = self.factory.makeProduct(name="project")
+        repository_db = self.factory.makeGitRepository(
+            owner=owner_db, target=project_db, name=u"repository")
+        webservice = webservice_for_person(
+            repository_db.owner, permission=OAuthPermission.READ_PUBLIC)
+        webservice.default_api_version = "devel"
+        with person_logged_in(ANONYMOUS):
+            repository_url = api_url(repository_db)
+        repository = webservice.get(repository_url).jsonBody()
+        self.assertEqual(
+            "https://git.launchpad.dev/~person/project/+git/repository";,
+            repository["git_https_url"])
+        self.assertEqual(
+            "git+ssh://git.launchpad.dev/~person/project/+git/repository",
+            repository["git_ssh_url"])
+
     def test_getRepositories_project(self):
         project_db = self.factory.makeProduct()
         repository_db = self.factory.makeGitRepository(target=project_db)


Follow ups