From 0dc92bf64305073eac3aa60175e7e436b1efaf8f Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Mon, 8 Jun 2020 17:58:18 +0200 Subject: [PATCH 1/3] Update formatting of diff notes (closes #14) --- commands/comments.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/commands/comments.py b/commands/comments.py index 67c1aa3..6596cd4 100644 --- a/commands/comments.py +++ b/commands/comments.py @@ -51,17 +51,19 @@ class Comments(BaseCommand): for file_path in comments[author]: if file_path is not None: - print(f"# `{file_path.split('/')[-1]}`") + filename = file_path.split('/')[-1] + print(f"\n`{filename}`\n{'-'*(len(filename) + 2)}") for comment in comments[author][file_path]: if comment["system"]: continue if comment["type"] == "DiffNote": body = comment["body"].replace( - "\n", "\n" + " " * (Comments.width + 2) + "\n", "\n" + " " * (len(str(comment["position"]["new_line"])) + 5) ) + print( - f"""{f'L{comment["position"]["new_line"]}':>{Comments.width}}: {body}""" + f"""- L{comment["position"]["new_line"]}: {body}""" ) else: print(f"""[{comment["created_at"]}]\n{comment["body"]}""") From a5b0ed9dc48c9357d61d29af1194d6237ed76e9f Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Mon, 8 Jun 2020 18:04:01 +0200 Subject: [PATCH 2/3] Create comment with skeleton of review (closes #15) --- commands/merge_requests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/commands/merge_requests.py b/commands/merge_requests.py index fd7b3be..667c87d 100644 --- a/commands/merge_requests.py +++ b/commands/merge_requests.py @@ -48,7 +48,7 @@ class MergeRequests(BaseGitCommand): mail = f"
\nMail\n\n
{submission.get_mail()}
" try: - self.gitlab.post_mr( + mr = self.gitlab.post_mr( source_branch=submission.branch, target_branch="master", title=f"[{submission.homework}{'-opravne' if submission.correction else ''}] {submission.login}", @@ -57,5 +57,6 @@ class MergeRequests(BaseGitCommand): remove_source_branch="true", assignee_ids=["1772"], ) + mr.comment(body="Summary\n=======\n\n# TODO\n\nDiff notes\n==========\n\n# TODO\n\nCorrection (YYYY/MM/DD)\n=======================\n\n# TODO") except: pass From 12c5fc610c44f1280f2ad3830aba04dcd3187515 Mon Sep 17 00:00:00 2001 From: Matej Focko Date: Mon, 8 Jun 2020 18:05:05 +0200 Subject: [PATCH 3/3] Reformat files --- commands/comments.py | 10 +++++----- commands/merge_requests.py | 4 +++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/commands/comments.py b/commands/comments.py index 6596cd4..101fcef 100644 --- a/commands/comments.py +++ b/commands/comments.py @@ -51,7 +51,7 @@ class Comments(BaseCommand): for file_path in comments[author]: if file_path is not None: - filename = file_path.split('/')[-1] + filename = file_path.split("/")[-1] print(f"\n`{filename}`\n{'-'*(len(filename) + 2)}") for comment in comments[author][file_path]: if comment["system"]: @@ -59,12 +59,12 @@ class Comments(BaseCommand): if comment["type"] == "DiffNote": body = comment["body"].replace( - "\n", "\n" + " " * (len(str(comment["position"]["new_line"])) + 5) + "\n", + "\n" + + " " * (len(str(comment["position"]["new_line"])) + 5), ) - print( - f"""- L{comment["position"]["new_line"]}: {body}""" - ) + print(f"""- L{comment["position"]["new_line"]}: {body}""") else: print(f"""[{comment["created_at"]}]\n{comment["body"]}""") print(header) diff --git a/commands/merge_requests.py b/commands/merge_requests.py index 667c87d..7fc2a7e 100644 --- a/commands/merge_requests.py +++ b/commands/merge_requests.py @@ -57,6 +57,8 @@ class MergeRequests(BaseGitCommand): remove_source_branch="true", assignee_ids=["1772"], ) - mr.comment(body="Summary\n=======\n\n# TODO\n\nDiff notes\n==========\n\n# TODO\n\nCorrection (YYYY/MM/DD)\n=======================\n\n# TODO") + mr.comment( + body="Summary\n=======\n\n# TODO\n\nDiff notes\n==========\n\n# TODO\n\nCorrection (YYYY/MM/DD)\n=======================\n\n# TODO" + ) except: pass