Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark mode
python-gitlabv3.0.0
python-gitlabv3.0.0

Table of Contents

FAQ

I cannot edit the merge request / issue I’ve just retrieved

It is likely that you used aMergeRequest,GroupMergeRequest,Issue orGroupIssue object. These objects cannot be edited. But youcan create a newProjectMergeRequest orProjectIssue object toapply changes. For example:

issue=gl.issues.list()[0]project=gl.projects.get(issue.project_id,lazy=True)editable_issue=project.issues.get(issue.iid,lazy=True)# you can now edit the object

See themerge requests example and theissues examples.

I get anAttributeError when accessing attributes of an object retrieved via alist() call.

Fetching a list of objects, doesn’t always include all attributes in theobjects. To retrieve an object with all attributes use aget() call.

Example with projects:

forprojectsingl.projects.list():# Retrieve project object with all attributesproject=gl.projects.get(project.id)
How can I clone the repository of a project?

python-gitlab doesn’t provide an API to clone a project. You have to use agit library or call thegit command.

The git URI is exposed in thessh_url_to_repo attribute ofProjectobjects.

Example:

importsubprocessproject=gl.projects.create(data)# or gl.projects.get(project_id)print(project.attributes)# displays all the attributesgit_url=project.ssh_url_to_reposubprocess.call(['git','clone',git_url])
I get anAttributeError when accessing attributes aftersave() orrefresh().

You are most likely trying to access an attribute that was not returnedby the server on the second request. Please look at the documentation inAttributes in updated objects to see how to avoid this.


[8]
ページ先頭

©2009-2025 Movatter.jp