#83 Allow multiple branches in collaborator permissions
Opened 2 years ago by pviktori. Modified 2 years ago
pviktori/fedscm-admin match_collaborator_branch  into  main

file modified
+16 -2
@@ -496,6 +496,20 @@ 

          return

  

  

+ def match_collaborator_branch(branch_name, branch_patterns):

+     """Return true if branch_name matches the given pattern.

+ 

+     Examples of patterns (from a src.fedoraproject.org settings page):

+         main,features/*

+         epel*

+         rawhide,f*

+     """

+     for pattern in branch_patterns.split(','):

+         if fnmatch.fnmatch(branch_name, pattern.strip()):

+             return True

+     return False

+ 

+ 

  def prompt_for_new_branch(issue_json, issue_body_json, force=False, auto_approve=False):

      """

      A helper function that prompts the user with information on a new branch
@@ -577,14 +591,14 @@ 

              set(contributors['users']['commit']) | \

              set(u['user']

                  for u in contributors['users']['collaborators']

-                 if fnmatch.fnmatch(branch_name, u['branches']))

+                 if match_collaborator_branch(branch_name, u['branches']))

  

          # Get the list of FAS groups who can maintain the package

          access_groups = set(contributors['groups']['admin']) | \

              set(contributors['groups']['commit']) | \

              set(g['user']

                  for g in contributors['groups']['collaborators']

-                 if fnmatch.fnmatch(branch_name, g['branches']))

+                 if match_collaborator_branch(branch_name, g['branches']))

          group_member = False

          for access_group in access_groups:

              # Check if the requestor is part of any of the FAS groups who can maintain the package

file modified
+1 -1
@@ -271,7 +271,7 @@ 

              'users': {

                  'admin': ['salimma'],

                  'collaborators': [{

-                     'branches': 'epel8',

+                     'branches': 'epel8,f20',

                      'user': 'ngompa'

                  }],

                  'commit': [],

According to the examples in collaborator permissions, it's possible
to specify several rules separated by commas:

 main,features/*
 epel*
 rawhide,f*

However, the new branch utility only allowed one. Here's a possible fix.

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

  • tox : FAILURE in 4m 25s

The tox failure is actually:

  lint: commands succeeded
ERROR:  py36: InterpreterNotFound: python3.6
  py37: commands succeeded
ERROR:  py38: InterpreterNotFound: python3.8
ERROR:  py39: InterpreterNotFound: python3.9

This change will also need to be applied to https://pagure.io/fedora-infra/toddlers/blob/main/f/toddlers/plugins/scm_request_processor.py. Eventually, fedscm-admin will stop being used and that toddler will automatically process SCM requests.