diff options
author | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-06-08 19:21:51 +0000 |
---|---|---|
committer | Ben Hutchings <ben.hutchings@codethink.co.uk> | 2020-06-08 19:21:51 +0000 |
commit | ae7af5d8de06804e75a9a6aca3ede1a75eb3acfb (patch) | |
tree | 6af1a6b2dc0ee7a890c3865cd6ca69396a4e858e | |
parent | e68d17adf03b7a203f4b5d75da175ee37e97ce45 (diff) | |
parent | 54d0672b8cfe7bc1273ce1631f3dc7c730198a45 (diff) | |
download | lorry-controller-ae7af5d8de06804e75a9a6aca3ede1a75eb3acfb.tar.gz |
Merge branch 'master' into 'bwh/gitea-support'
# Conflicts:
# lorry-controller-webapp
-rw-r--r-- | etc/lighttpd/lorry-controller-webapp-httpd.conf | 4 | ||||
-rw-r--r-- | lorrycontroller/gerrit.py | 40 |
2 files changed, 31 insertions, 13 deletions
diff --git a/etc/lighttpd/lorry-controller-webapp-httpd.conf b/etc/lighttpd/lorry-controller-webapp-httpd.conf index 206371e..68f67c5 100644 --- a/etc/lighttpd/lorry-controller-webapp-httpd.conf +++ b/etc/lighttpd/lorry-controller-webapp-httpd.conf @@ -20,13 +20,15 @@ $SERVER["socket"] == "127.0.0.1:12765" { server.username = "lorry" server.groupname = "lorry" fastcgi.server = ( - "" => + "/" => ( "python-fcgi" => ( "socket" => "/run/lighttpd-lorry/lorry-controller-webapp.socket", "bin-path" => "/usr/bin/lorry-controller-webapp --config=/etc/lorry-controller/webapp.conf", "check-local" => "disable", + # Pass full request path as PATH_INFO + "fix-root-scriptname" => "enable", "max-procs" => 1, ) ) diff --git a/lorrycontroller/gerrit.py b/lorrycontroller/gerrit.py index 5a35920..c2c81b8 100644 --- a/lorrycontroller/gerrit.py +++ b/lorrycontroller/gerrit.py @@ -31,6 +31,14 @@ class GerritDownstream(hosts.DownstreamHost): ''' @staticmethod + def add_app_settings(app_settings): + app_settings.string( + ['gerrit-parent-project'], + 'parent project for repositories on Gerrit', + default='All-Projects', + metavar='PROJECT') + + @staticmethod def check_app_settings(app_settings): if app_settings['downstream-visibility'] != 'private': raise cliapp.ApplicationError( @@ -46,6 +54,8 @@ class GerritDownstream(hosts.DownstreamHost): self._ssh_command = hosts.SshCommand( url, StrictHostKeyChecking=key_check) + self._parent_project = app_settings['gerrit-parent-project'] + def _has_project(self, name): # There's no 'does this project exist' command in Gerrit 2.9.4; 'list # all projects with this prefix' is as close we can get. @@ -69,18 +79,24 @@ class GerritDownstream(hosts.DownstreamHost): if self._has_project(name): logging.info('Project %s exists in local Gerrit already.', name) - else: - self._ssh_command.run(['gerrit', 'create-project', name]) - logging.info('Created %s project in local Gerrit.', name) - # We can only set this metadata if we're the owner of the - # repository. For now, ignore failures. - try: + # We can only set this metadata if we're the owner of the + # repository. For now, ignore failures. + try: + if 'head' in metadata: + self._ssh_command.run(['gerrit', 'set-head', name, + '--new-head', metadata['head']]) + if 'description' in metadata: + self._ssh_command.run(['gerrit', 'set-project', name, + '-d', metadata['description']]) + except cliapp.AppException: + pass + else: + create_args = ['gerrit', 'create-project', name, + '-p', self._parent_project] if 'head' in metadata: - self._ssh_command.run(['gerrit', 'set-head', name, - '--new-head', metadata['head']]) + create_args.extend(['-b', metadata['head']]) if 'description' in metadata: - self._ssh_command.run(['gerrit', 'set-project', name, - '-d', metadata['description']]) - except cliapp.AppException: - pass + create_args.extend(['-d', metadata['description']]) + self._ssh_command.run(create_args) + logging.info('Created %s project in local Gerrit.', name) |