launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #24186
[Merge] ~ilasc/launchpad:add-mp-url-to-git-push into launchpad:master
Ioana Lasc has proposed merging ~ilasc/launchpad:add-mp-url-to-git-push into launchpad:master.
Commit message:
Add MP URL to git push
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/377044
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilasc/launchpad:add-mp-url-to-git-push into launchpad:master.
diff --git a/lib/lp/code/interfaces/gitapi.py b/lib/lp/code/interfaces/gitapi.py
index c7db491..7a01517 100644
--- a/lib/lp/code/interfaces/gitapi.py
+++ b/lib/lp/code/interfaces/gitapi.py
@@ -79,3 +79,10 @@ class IGitAPI(Interface):
:returns: A list of rules for the user in the specified repository
"""
+
+ def getMPurlRPC(translated_paths, branch, auth_params):
+ """Return the URL for a Merge Proposal for a `branch` in a `repository`..
+
+ :returns: The URL for a Merge Proposal for the branch in the
+ specified repository
+ """
\ No newline at end of file
diff --git a/lib/lp/code/xmlrpc/git.py b/lib/lp/code/xmlrpc/git.py
index cbf9205..61dbbe2 100644
--- a/lib/lp/code/xmlrpc/git.py
+++ b/lib/lp/code/xmlrpc/git.py
@@ -24,6 +24,7 @@ from zope.error.interfaces import IErrorReportingUtility
from zope.interface import implementer
from zope.security.interfaces import Unauthorized
from zope.security.proxy import removeSecurityProxy
+from lp.services.config import config
from lp.app.errors import NameLookupFailed
from lp.app.validators import LaunchpadValidationError
@@ -54,6 +55,7 @@ from lp.code.interfaces.gitnamespace import (
split_git_unique_name,
)
from lp.code.interfaces.gitrepository import IGitRepositorySet
+from lp.code.model.branch import Branch
from lp.code.xmlrpc.codehosting import run_with_login
from lp.registry.errors import (
InvalidName,
@@ -72,7 +74,7 @@ from lp.services.macaroons.interfaces import (
IMacaroonIssuer,
NO_USER,
)
-from lp.services.webapp import LaunchpadXMLRPCView
+from lp.services.webapp import LaunchpadXMLRPCView, canonical_url
from lp.services.webapp.authorization import check_permission
from lp.services.webapp.errorlog import ScriptRequest
from lp.xmlrpc import faults
@@ -426,6 +428,25 @@ class GitAPI(LaunchpadXMLRPCView):
removeSecurityProxy(repository))
logger.info("notify succeeded")
+ def getMPurlRPC(self, translated_path, branch):
+ """See `IGitAPI`."""
+ logger = self._getLogger()
+ logger.info("Request received: getMPurlRPC('%s')", translated_path)
+ repository = getUtility(IGitLookup).getByHostingPath(translated_path)
+ if repository is None:
+ fault = faults.NotFound(
+ "No repository found for '%s'." % translated_path)
+ logger.error("getMPurlRPC failed: %r", fault)
+ return fault
+
+ base_url = canonical_url(repository, rootsite='code')
+ if 'refs/heads/'+branch != repository.default_branch:
+ mp_url = (base_url+'/+ref/'+branch+'/+register-merge')
+ logger.info("getMPurlRPC succeeded in forming MP URL : '%s'" % mp_url)
+ return mp_url
+
+ logger.info("getMPurlRPC succeeded")
+
@return_fault
def _authenticateWithPassword(self, username, password):
"""Authenticate a user by username and password.
Follow ups