From b5eead3e37cc63fc12f4d46d20159a960b48892e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 08 2018 09:17:10 +0000 Subject: [PATCH 1/2] Add a way to block non fast-forwardable commits on all branches Fixes https://pagure.io/pagure/issue/1988 Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/hooks/files/pagure_force_commit_hook.py b/pagure/hooks/files/pagure_force_commit_hook.py index 5b1b18c..7aef071 100755 --- a/pagure/hooks/files/pagure_force_commit_hook.py +++ b/pagure/hooks/files/pagure_force_commit_hook.py @@ -46,16 +46,11 @@ def run_as_pre_receive_hook(): plugin = pagure.lib.plugins.get_plugin('Block non fast-forward pushes') plugin.db_object() # Get the list of branches - branches = [ + branches = [] + if repo.pagure_force_commit_hook: branch.strip() for branch in repo.pagure_force_commit_hook.branches.split(',') - if repo.pagure_force_commit_hook] - - # Remove empty branches - branches = [ - branch.strip() - for branch in branches - if branch] + if branch.strip()] for line in sys.stdin: if _config.get('HOOK_DEBUG', False): @@ -63,7 +58,7 @@ def run_as_pre_receive_hook(): (oldrev, newrev, refname) = line.strip().split(' ', 2) refname = refname.replace('refs/heads/', '') - if refname in branches: + if refname in branches or branches == ['*']: if _config.get('HOOK_DEBUG', False): print(' -- Old rev') print(oldrev) diff --git a/pagure/hooks/pagure_force_commit.py b/pagure/hooks/pagure_force_commit.py index 5ec8fe1..d389405 100644 --- a/pagure/hooks/pagure_force_commit.py +++ b/pagure/hooks/pagure_force_commit.py @@ -70,7 +70,9 @@ class PagureForceCommitHook(BaseHook): name = 'Block non fast-forward pushes' description = 'Using this hook you can block any non-fast-forward '\ - 'commit forced pushed to one or more branches' + 'commit forced pushed to one or more branches.\n'\ + 'You can specify one or more branch names (sperated them using '\ + 'commas) or block all the branches by specifying: ``*``' form = PagureForceCommitForm db_object = PagureForceCommitTable backref = 'pagure_force_commit_hook' From b80bbf8deb0cc9fa1deaec1e4bc9bd20f9fd2180 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 08 2018 09:17:10 +0000 Subject: [PATCH 2/2] Fix the counter to make the accordion working correctly Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index 51900de..73f9010 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -563,27 +563,28 @@
- {% set idcount = 1 %} + {% for plugin in plugins %} {% if not config.get('ENABLE_TICKETS', True) and plugin in ['Pagure tickets'] %} {% else %}
- - {% set idcount = idcount+1 %} {% endif %} {% endfor %}