0
import gitlab
gl = gitlab.Gitlab('http://gitlab.mycompany', private_token=access_token)
gl.auth()
projects = gl.projects.list()
pres = projects[0]
for project in projects:
    if 'myprojectname' in str(project):
        print(project)
        pres = project
# do something with pres

I'm trying to use Gitlab library in Python. When I print str(project), it does not include info about who creates the repo. Also, when I run

for member in pres.members.list():
    print(member)

It only prints the invited member, it doesn't print the owner or the people who own the repo group.

Is it possible to find who creates a Gitlab repo?

Huy Le
  • 1,439
  • 4
  • 19

2 Answers2

2

The ID of the project creator is exposed in the creator_id attribute in the projects endpoint (see upstream API docs at https://docs.gitlab.com/ee/api/projects.html#list-all-projects).

You can then use the Users API to get more details on the creator user (as described in https://python-gitlab.readthedocs.io/en/stable/gl_objects/users.html):

import gitlab
gl = gitlab.Gitlab('http://gitlab.mycompany', private_token=access_token)
gl.auth()
projects = gl.projects.list(as_list=False)

for project in projects:
    creator = gl.users.get(project.creator_id)
    print(creator.username)
nejc
  • 181
  • 3
0

Search here for project members: https://python-gitlab.readthedocs.io/en/stable/gl_objects/projects.html#project-members

There are more options you can try: PY-API built-in functions

and last but not least if you can't find a way to solve your problems you can always do the trick with using pure gitlab API through requests module to https://docs.gitlab.com/ee/api/members.html

PCastedo
  • 74
  • 5