Movatterモバイル変換


[0]ホーム

URL:


ContentsMenuExpandLight modeDark modeAuto light/dark, in light modeAuto light/dark, in dark modeSkip to content
python-gitlabv6.1.0
python-gitlabv6.1.0

Table of Contents

Back to top

Discussions

Discussions organize the notes in threads. See theNotes chapterfor more information about notes.

Discussions are available for project issues, merge requests, snippets andcommits.

Reference

Examples

List the discussions for a resource (issue, merge request, snippet or commit):

discussions=resource.discussions.list(get_all=True)

Get a single discussion:

discussion=resource.discussions.get(discussion_id)

You can access the individual notes in the discussion through thenotesattribute. It holds a list of notes in chronological order:

# ``resource.notes`` is a DiscussionNoteManager, so we need to get the# object notes using ``attributes``fornoteindiscussion.attributes['notes']:print(note['body'])

Note

The notes are dicts, not objects.

You can add notes to existing discussions:

new_note=discussion.notes.create({'body':'Episode IV: A new note'})

You can get and update a single note using the*DiscussionNote resources:

discussion=resource.discussions.get(discussion_id)# Get the latest note's idnote_id=discussion.attributes['notes'][-1]['id']last_note=discussion.notes.get(note_id)last_note.body='Updated comment'last_note.save()

Create a new discussion:

discussion=resource.discussions.create({'body':'First comment of discussion'})

You can comment on merge requests and commit diffs. Provide thepositiondict to define where the comment should appear in the diff:

mr_diff=mr.diffs.get(diff_id)mr.discussions.create({'body':'Note content','position':{'base_sha':mr_diff.base_commit_sha,'start_sha':mr_diff.start_commit_sha,'head_sha':mr_diff.head_commit_sha,'position_type':'text','new_line':1,'old_path':'README.rst','new_path':'README.rst'}})

Resolve / unresolve a merge request discussion:

mr_d=mr.discussions.get(d_id)mr_d.resolved=True# True to resolve, False to unresolvemr_d.save()

Delete a comment:

discussions.notes.delete(note_id)# ornote.delete()
On this page

[8]ページ先頭

©2009-2025 Movatter.jp