Mercurial > kallithea
changeset 7128:85d812ab4c64
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.
author | Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> |
---|---|
date | Fri, 09 Feb 2018 20:18:52 +0100 |
parents | f235038d6902 |
children | e12c4a3ce996 |
files | kallithea/controllers/api/api.py kallithea/model/scm.py |
diffstat | 2 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/controllers/api/api.py Sun Feb 11 00:26:52 2018 +0100 +++ b/kallithea/controllers/api/api.py Fri Feb 09 20:18:52 2018 +0100 @@ -171,7 +171,7 @@ 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 @@ :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 @@ 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
--- a/kallithea/model/scm.py Sun Feb 11 00:26:52 2018 +0100 +++ b/kallithea/model/scm.py Fri Feb 09 20:18:52 2018 +0100 @@ -388,12 +388,13 @@ 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")