diff --git a/kallithea/controllers/api/api.py b/kallithea/controllers/api/api.py --- a/kallithea/controllers/api/api.py +++ b/kallithea/controllers/api/api.py @@ -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 diff --git a/kallithea/model/scm.py b/kallithea/model/scm.py --- a/kallithea/model/scm.py +++ b/kallithea/model/scm.py @@ -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")