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?

2 Answers 2

3

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)
Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

it shows the member, but doesn't show who actually created the repo.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.