From 355f95ce6a468acf03e7dd40bb57660ccb27bc0b Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 06 2017 20:00:34 +0000 Subject: Split generate_gitolite_acls into two method The first one generates the command to be run, the second actually runs it. This allows displaying which command is going to be run without necessarily running it. --- diff --git a/pagure/lib/git.py b/pagure/lib/git.py index 40c41da..d881301 100644 --- a/pagure/lib/git.py +++ b/pagure/lib/git.py @@ -137,12 +137,10 @@ def write_gitolite_acls(session, configfile): stream.write(row + '\n') -def generate_gitolite_acls(): - """ Generate the gitolite configuration file for all repos +def _get_gitolite_command(): + """ Return the gitolite command to run based on the info in the + configuration file. """ - pagure.lib.git.write_gitolite_acls( - pagure.SESSION, pagure.APP.config['GITOLITE_CONFIG']) - gitolite_folder = pagure.APP.config.get('GITOLITE_HOME', None) gitolite_version = pagure.APP.config.get('GITOLITE_VERSION', 3) if gitolite_folder: @@ -161,6 +159,17 @@ def generate_gitolite_acls(): raise pagure.exceptions.PagureException( 'Non-supported gitolite version "%s"' % gitolite_version ) + return cmd + + +def generate_gitolite_acls(): + """ Generate the gitolite configuration file for all repos + """ + pagure.lib.git.write_gitolite_acls( + pagure.SESSION, pagure.APP.config['GITOLITE_CONFIG']) + + cmd = _get_gitolite_command() + if cmd: subprocess.Popen( cmd, shell=True,