Changeset - 85d812ab4c64
[Not reviewed]
default
0 2 0
Thomas De Schampheleire - 8 years ago 2018-02-09 20:18:52
thomas.de_schampheleire@nokia.com
api: allow pulling from a custom remote

The 'pull' API call would currently pull from the configured repository
remote or the fork origin in case of a fork.

This commit allows to specify an optional 'clone_uri' parameter to the API
call that will be used during the pull.
2 files changed with 8 insertions and 4 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/api/api.py
Show inline comments
 
@@ -171,7 +171,7 @@ class ApiController(JSONRPCController):
 
        return args
 

	
 
    @HasPermissionAnyDecorator('hg.admin')
 
    def pull(self, repoid):
 
    def pull(self, repoid, clone_uri=Optional(None)):
 
        """
 
        Triggers a pull from remote location on given repo. Can be used to
 
        automatically keep remote repos up to date. This command can be executed
 
@@ -179,6 +179,8 @@ class ApiController(JSONRPCController):
 

	
 
        :param repoid: repository name or repository id
 
        :type repoid: str or int
 
        :param clone_uri: repository URI to pull from (optional)
 
        :type clone_uri: str
 

	
 
        OUTPUT::
 

	
 
@@ -203,7 +205,8 @@ class ApiController(JSONRPCController):
 

	
 
        try:
 
            ScmModel().pull_changes(repo.repo_name,
 
                                    request.authuser.username)
 
                                    request.authuser.username,
 
                                    clone_uri=Optional.extract(clone_uri))
 
            return dict(
 
                msg='Pulled from `%s`' % repo.repo_name,
 
                repository=repo.repo_name
kallithea/model/scm.py
Show inline comments
 
@@ -388,12 +388,13 @@ class ScmModel(object):
 
        raise Exception('Invalid scm_type, must be one of hg,git got %s'
 
                        % (scm_type,))
 

	
 
    def pull_changes(self, repo, username):
 
    def pull_changes(self, repo, username, clone_uri=None):
 
        """
 
        Pull from "clone URL" or fork origin.
 
        """
 
        dbrepo = self.__get_repo(repo)
 
        clone_uri = dbrepo.clone_uri or dbrepo.fork and dbrepo.fork.repo_full_path
 
        if clone_uri is None:
 
            clone_uri = dbrepo.clone_uri or dbrepo.fork and dbrepo.fork.repo_full_path
 
        if not clone_uri:
 
            raise Exception("This repository doesn't have a clone uri")
 

	
0 comments (0 inline, 0 general)