diff --git a/gerritlib/gerrit.py b/gerritlib/gerrit.py index 300df2d..6b8e28b 100644 --- a/gerritlib/gerrit.py +++ b/gerritlib/gerrit.py @@ -347,9 +347,19 @@ class Gerrit(object): cmd = 'gerrit ls-groups -v' else: cmd = 'gerrit ls-groups' + version = None + try: + version = self.parseGerritVersion(self.getVersion()) + except Exception: + # If no version then we know version is old and should use -q + pass + if not version or version < (2, 14): + query_flag = '-q' + else: + query_flag = '-g' # ensure group names with spaces are escaped and quoted group = "\"%s\"" % group.replace(' ', r'\ ') - out, err = self._ssh(' '.join([cmd, '-q', group])) + out, err = self._ssh(' '.join([cmd, query_flag, group])) return list(filter(None, out.split('\n'))) def listPlugins(self): diff --git a/playbooks/jeepyb-integration/run.yaml b/playbooks/jeepyb-integration/run.yaml index 888aa63..e0341a5 100644 --- a/playbooks/jeepyb-integration/run.yaml +++ b/playbooks/jeepyb-integration/run.yaml @@ -71,6 +71,19 @@ shell: cmd: PROJECTS_INI=tools/projects.ini PROJECTS_YAML=tools/projects.yaml manage-projects -v chdir: src/opendev.org/opendev/gerritlib + - name: Change test-repo-1 acls but don't change groups + lineinfile: + path: src/opendev.org/opendev/gerritlib/tools/projects.yaml + regexp: '^ acl-config: tools/acls/test/test.config' + line: ' acl-config: tools/acls/test/test2.config' + - name: Update single gerrit project with new acl + shell: + cmd: PROJECTS_INI=tools/projects.ini PROJECTS_YAML=tools/projects.yaml manage-projects -v test/test-repo-1 + chdir: src/opendev.org/opendev/gerritlib + - name: Manage all gerrit projects again after acl update + shell: + cmd: PROJECTS_INI=tools/projects.ini PROJECTS_YAML=tools/projects.yaml manage-projects -v + chdir: src/opendev.org/opendev/gerritlib - name: Check test-repo-1 exists shell: cmd: ssh -i tools/sshkey/admin -p 29418 admin@localhost gerrit ls-projects | grep test-repo-1 diff --git a/tools/acls/test/test.config b/tools/acls/test/test.config index 5748653..8ca7fcc 100644 --- a/tools/acls/test/test.config +++ b/tools/acls/test/test.config @@ -1,7 +1,13 @@ [access "refs/heads/*"] abandon = group Registered Users +abandon = group test-group +abandon = group Test Group With Spaces label-Code-Review = -2..+2 group Registered Users +label-Code-Review = -2..+2 group test-group +label-Code-Review = -2..+2 group Test Group With Spaces label-Workflow = -1..+1 group Registered Users +label-Workflow = -1..+1 group test-group +label-Workflow = -1..+1 group Test Group With Spaces [receive] requireChangeId = true diff --git a/tools/acls/test/test2.config b/tools/acls/test/test2.config new file mode 100644 index 0000000..1f6ddb7 --- /dev/null +++ b/tools/acls/test/test2.config @@ -0,0 +1,14 @@ +[access "refs/heads/*"] +abandon = group Registered Users +abandon = group Test Group With Spaces +label-Code-Review = -2..+2 group Registered Users +label-Code-Review = -2..+2 group test-group +label-Code-Review = -2..+2 group Test Group With Spaces +label-Workflow = -1..+1 group Registered Users +label-Workflow = -1..+1 group test-group + +[receive] +requireChangeId = true + +[submit] +mergeContent = true