mirror of
https://git.centos.org/centos/centpkg.git
synced 2025-02-24 00:32:55 +00:00
Disabling pushing to c9s branch in the fork
Signed-off-by: Mohan Boddu <mboddu@bhujji.com>
This commit is contained in:
parent
329e001c49
commit
464a71d87f
1 changed files with 26 additions and 0 deletions
|
@ -63,6 +63,32 @@ def do_fork(logger, base_url, token, repo_name, namespace, cli_name):
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if rv.ok:
|
||||||
|
fork_id = rv.json()['id']
|
||||||
|
try:
|
||||||
|
# Unprotect c9s in fork
|
||||||
|
rv = requests.delete('{0}/projects/{1}/protected_branches/{2}'.format(api_url, fork_id, 'c9s'), headers=header)
|
||||||
|
except ConnectionError as error:
|
||||||
|
error_msg = ('The connection to API failed while trying to unprotect c9s branch'
|
||||||
|
'in the fork. The error was: {0}'.format(str(error)))
|
||||||
|
raise rpkgError(error_msg)
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Reprotect c9s to disable pushes
|
||||||
|
# Only maintainers in gitlab are allowed to push with the following config
|
||||||
|
# In CS, every pkg maintainer is considered as a developer in gitlab
|
||||||
|
data = {'id': fork_id,
|
||||||
|
'name': 'c9s',
|
||||||
|
'allowed_to_push': [{'access_level': 40}],
|
||||||
|
'allowed_to_merge': [{'access_level': 40}],
|
||||||
|
}
|
||||||
|
rv = requests.post('{0}/projects/{1}/protected_branches'.format(api_url, fork_id), json=data, headers=header)
|
||||||
|
except ConnectionError as error:
|
||||||
|
error_msg = ('The connection to API failed while trying to reprotect c9s branch'
|
||||||
|
'in the fork fork. The error was: {0}'.format(str(error)))
|
||||||
|
raise rpkgError(error_msg)
|
||||||
|
|
||||||
base_error_msg = ('The following error occurred while creating a new fork: {0}')
|
base_error_msg = ('The following error occurred while creating a new fork: {0}')
|
||||||
if not rv.ok:
|
if not rv.ok:
|
||||||
# fork was already created
|
# fork was already created
|
||||||
|
|
Loading…
Add table
Reference in a new issue