Table of Contents
gitlab package)gitlab command)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.
AttributeError 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)
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])
AttributeError 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.