summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2021-09-24 20:02:02 -0300
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-09-28 15:50:27 +0000
commit1f9ba472284c798f3221cef3fc5bf8efbdc1327e (patch)
treed9727e6dada032c84b07872981b8ea5e0515c2a3 /scripts
parent085a4a9ec4ab9034cfe36dc62c89a834e9dca7de (diff)
downloadgstreamer-1f9ba472284c798f3221cef3fc5bf8efbdc1327e.tar.gz
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>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/move_mrs_to_monorepo.py32
1 files changed, 26 insertions, 6 deletions
diff --git a/scripts/move_mrs_to_monorepo.py b/scripts/move_mrs_to_monorepo.py
index 8a71c88e7a..1c491566d0 100755
--- a/scripts/move_mrs_to_monorepo.py
+++ b/scripts/move_mrs_to_monorepo.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
-from pathlib import Path
from urllib.parse import urlparse
from contextlib import contextmanager
import os
@@ -10,7 +9,15 @@ try:
import gitlab
except ModuleNotFoundError:
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)
sys.exit(1)
import argparse
@@ -309,15 +316,28 @@ class GstMRMover:
new_discussion = None
for note in notes:
- note_url = f"{mr_url}#note_{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 = discussion.notes.get(note['id'])
+
+ 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:
new_discussion.notes.create(obj)
else:
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)
print(f"New MR available at: {bold(new_mr_url)}\n")