From 8bc00630c77a8d4ef1402b0e6661708a71768a3e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Aug 21 2017 09:26:01 +0000 Subject: Adjust the logic to group the users and groups in a single line This mimic the behavior we had before and help reading the configuration file. Signed-off-by: Pierre-Yves Chibon --- diff --git a/dist_git_auth.py b/dist_git_auth.py index c188d80..01ce9d2 100644 --- a/dist_git_auth.py +++ b/dist_git_auth.py @@ -116,35 +116,33 @@ class DistGitoliteAuth(Gitolite3Auth): if project.is_fork: access = 'RW+C' + users = sorted(set([project.user.user]).union( + set([ + user.user + for user in project.committers + if user != project.user]))) + groups = sorted(set([ + group.group_name + for group in project.committer_groups + ])) + if repos == '' and not project.is_fork: + groups.append('provenpackager') # First, whitelist the supported branches from PDC for branch in get_supported_branches( project.namespace, project.name): config.append(' %s %s = %s' % ( - access, branch, project.user.user)) - for user in project.committers: - if user != project.user: - config.append(' %s %s = %s' % ( - access, branch, user.user)) + access, branch, ' '.join(users) + ) + ) # Then, blacklist a pattern over that (after). config.append(_blacklist) - if repos == '' and not project.is_fork: - config.append(' %s = @provenpackager' % (access, )) - - if project.committer_groups: - config.append(' %s = @%s' % (access, ' @'.join( - [ - group.group_name - for group in project.committer_groups - ] - ))) - - config.append(' %s = %s' % (access, project.user.user)) - for user in project.committers: - if user != project.user: - config.append(' %s = %s' % (access, user.user)) + if groups: + config.append(' %s = @%s' % (access, ' @'.join(groups))) + + config.append(' %s = %s' % (access, ' '.join(users))) for deploykey in project.deploykeys: access = 'R' diff --git a/dist_git_auth_tests.py b/dist_git_auth_tests.py index 4ef8ce8..3ee4f5e 100644 --- a/dist_git_auth_tests.py +++ b/dist_git_auth_tests.py @@ -196,22 +196,18 @@ repo requests/somenamespace/test3 repo test R = @all - RWC master = foo - RWC master = pingou - RWC f9000 = foo - RWC f9000 = pingou + RWC master = foo pingou + RWC f9000 = foo pingou - f[0-9][0-9] = @all - epel[0-9] = @all - epel[0-9][0-9] = @all - el[0-9] = @all - olpc[0-9] = @all RWC = @provenpackager - RWC = foo - RWC = pingou + RWC = foo pingou repo requests/test - RWC = foo - RWC = pingou + RWC = foo pingou # end of body''' self.assertMultiLineEqual(expected, contents.strip()) @@ -313,8 +309,7 @@ repo test - epel[0-9][0-9] = @all - el[0-9] = @all - olpc[0-9] = @all - RWC = @provenpackager - RWC = @test_grp + RWC = @test_grp @provenpackager RWC = foo repo requests/test