Merge "Add config option for git clone URL"

This commit is contained in:
Jenkins 2016-03-10 16:37:53 +00:00 committed by Gerrit Code Review
commit 44fd26d781
4 changed files with 11 additions and 1 deletions

View File

@ -32,6 +32,10 @@ servers:
# Gertty will not modify them unless you tell it to, and even then the
# normal git protections against losing work remain in place. [required]
# git-root: ~/git/
# The URL to clone git repos. By default, <url>/p/<project> is used. For a list
# of valid URLs, see:
# https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS
# git-url: ssh://user@example.org:29418
# The location of Gertty's sqlite database. If you have more than one
# server, you should specify a dburi for any additional servers.
# By default a SQLite database called ~/.gertty.db is used.

View File

@ -46,6 +46,7 @@ class ConfigSchema(object):
'ssl-ca-path': str,
'dburi': str,
v.Required('git-root'): str,
'git-url': str,
'log-file': str,
'socket': str,
'auth-type': str,
@ -177,6 +178,10 @@ class Config(object):
# And this is to allow Git callouts
os.environ['GIT_SSL_CAINFO'] = self.ssl_ca_path
self.git_root = os.path.expanduser(server['git-root'])
git_url = server.get('git-url', self.url + 'p/')
if not git_url.endswith('/'):
git_url += '/'
self.git_url = git_url
self.dburi = server.get('dburi',
'sqlite:///' + os.path.expanduser('~/.gertty.db'))
socket_path = server.get('socket', '~/.gertty.sock')

View File

@ -517,4 +517,4 @@ def get_repo(project_name, config):
local_path = os.path.join(config.git_root, project_name)
local_root = os.path.abspath(config.git_root)
assert os.path.commonprefix((local_root, local_path)) == local_root
return Repo(config.url+'p/'+project_name, local_path)
return Repo(config.git_url + project_name, local_path)

View File

@ -607,6 +607,7 @@ class SyncChangeTask(Task):
for remote_commit, remote_revision in remote_change.get('revisions', {}).items():
revision = session.getRevisionByCommit(remote_commit)
# TODO: handle multiple parents
url = sync.app.config.git_url + change.project.name
if 'anonymous http' in remote_revision['fetch']:
ref = remote_revision['fetch']['anonymous http']['ref']
url = remote_revision['fetch']['anonymous http']['url']