python-gitlab / python-gitlab

A python wrapper for the GitLab API.

Home Page:https://python-gitlab.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Merge request note update appends instead of replaces

Flamefire opened this issue · comments

Description of the problem, including code/CLI snippet

I want to update a comment on a merge request. For that I use:

    mr = gitlab_project.mergerequests.get(mr_iid)
    match_str = find_comment_match(comment)
    try:
        existing_note = None
        for note in mr.notes.list():
            if find_comment_match(note.body) == match_str:
                existing_note = note
        if existing_note:
            existing_note.body = comment
            existing_note.save()

Expected Behavior

Comment gets replaced by the new text

Actual Behavior

New comment is appended to the text of the old comment

Specifications

  • python-gitlab version: 2.10.1
  • API version you are using (v3/v4): ?
  • Gitlab server version: v16.10.5

Can you try with the latest version of python-gitlab?

Looks like it was a mistake on my side. Tried to reproduce it in a small testcase but failed