Add config option for git clone URL
This commit adds a new config option 'git-url', where the base URL can be specified to anything recognised by git-clone: https://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS This is useful if the values provided by gerrit are incorrect, or if you have access to a gerrit mirror closer to you. Change-Id: I35ee5540aad2f27125ec15e6e933ac1ad3f3050e
This commit is contained in:
parent
b33cbc0a7a
commit
5479310d75
@ -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.
|
||||
|
@ -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')
|
||||
|
@ -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)
|
||||
|
@ -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']
|
||||
|
Loading…
x
Reference in New Issue
Block a user