mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
move-mrs-script: Add a notion of when comments where added
And resolve already resolved discussions Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/919>
This commit is contained in:
parent
085a4a9ec4
commit
1f9ba47228
1 changed files with 26 additions and 6 deletions
|
@ -1,6 +1,5 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from pathlib import Path
|
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
import os
|
import os
|
||||||
|
@ -10,7 +9,15 @@ try:
|
||||||
import gitlab
|
import gitlab
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
print("========================================================================", file=sys.stderr)
|
print("========================================================================", file=sys.stderr)
|
||||||
print("ERROR: Install python-gitlab with `python3 -m pip install python-gitlab`", file=sys.stderr)
|
print("ERROR: Install python-gitlab with `python3 -m pip install python-gitlab dateutil`", file=sys.stderr)
|
||||||
|
print("========================================================================", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
try:
|
||||||
|
from dateutil import parser as dateparse
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
print("========================================================================", file=sys.stderr)
|
||||||
|
print("ERROR: Install dateutil with `python3 -m pip install dateutil`", file=sys.stderr)
|
||||||
print("========================================================================", file=sys.stderr)
|
print("========================================================================", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -309,15 +316,28 @@ class GstMRMover:
|
||||||
|
|
||||||
new_discussion = None
|
new_discussion = None
|
||||||
for note in notes:
|
for note in notes:
|
||||||
note_url = f"{mr_url}#note_{note['id']}"
|
note = discussion.notes.get(note['id'])
|
||||||
body = f"**{note['author']['name']} - {PING_SIGN}{note['author']['username']} wrote [here]({note_url})**:\n\n"
|
|
||||||
body += '\n'.join([l for l in note['body'].split('\n')])
|
note_url = f"{mr_url}#note_{note.id}"
|
||||||
|
when = dateparse.parse(note.created_at).strftime('on %d, %b %Y')
|
||||||
|
body = f"**{note.author['name']} - {PING_SIGN}{note.author['username']} wrote [here]({note_url})** {when}:\n\n"
|
||||||
|
body += '\n'.join([l for l in note.body.split('\n')])
|
||||||
|
|
||||||
|
obj = {
|
||||||
|
'body': body,
|
||||||
|
'type': note.type,
|
||||||
|
'resolvable': note.resolvable,
|
||||||
|
}
|
||||||
|
|
||||||
obj = {'body': body, 'type': note['type']}
|
|
||||||
if new_discussion:
|
if new_discussion:
|
||||||
new_discussion.notes.create(obj)
|
new_discussion.notes.create(obj)
|
||||||
else:
|
else:
|
||||||
new_discussion = new_mr.discussions.create(obj)
|
new_discussion = new_mr.discussions.create(obj)
|
||||||
|
|
||||||
|
if not note.resolvable or note.resolved:
|
||||||
|
new_discussion.resolved = True
|
||||||
|
new_discussion.save()
|
||||||
|
|
||||||
fprint(f"{green(' OK')}\n", nested=False)
|
fprint(f"{green(' OK')}\n", nested=False)
|
||||||
|
|
||||||
print(f"New MR available at: {bold(new_mr_url)}\n")
|
print(f"New MR available at: {bold(new_mr_url)}\n")
|
||||||
|
|
Loading…
Reference in a new issue