[PATCH] comments: avoid confusing 'No comments' on empty general comments
Thomas De Schampheleire
patrickdepinguin at gmail.com
Sat Apr 18 16:12:22 EDT 2015
# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1429294302 -7200
# Fri Apr 17 20:11:42 2015 +0200
# Node ID e25ee448dae32e2e21f1b66763dae468f45c00f0
# Parent a7cc66bf51ec89134cb7b02aca044bb74a56f768
comments: avoid confusing 'No comments' on empty general comments
When a general comment (with or without status change) is added to a changeset
or pull request, and no text was added, Kallithea automatically used 'No
comments' as text. This is confusing when the reviewer has added one or more
inline comments.
Instead, use '(status change only)'. In the case where a user added
a comment without text and without status change (for example when closing a
pull requesh), use '(no comments added)'.
Currently there is a large amount of duplication between
controllers/changeset.py and controllers/pullrequests.py, which is to be
cleaned up in a later commit.
diff --git a/kallithea/controllers/changeset.py b/kallithea/controllers/changeset.py
--- a/kallithea/controllers/changeset.py
+++ b/kallithea/controllers/changeset.py
@@ -349,7 +349,15 @@
@jsonify
def comment(self, repo_name, revision):
status = request.POST.get('changeset_status')
- text = request.POST.get('text', '').strip() or _('No comments.')
+ status_change = ChangesetStatus.get_status_lbl(status) if status else None
+
+ text = request.POST.get('text', '').strip()
+ if not text:
+ if status_change:
+ text = _('(status change only)')
+ else:
+ # useless comment without text and without status change
+ text = _('(no comments added)')
c.co = comm = ChangesetCommentsModel().create(
text=text,
@@ -358,8 +366,7 @@
revision=revision,
f_path=request.POST.get('f_path'),
line_no=request.POST.get('line'),
- status_change=(ChangesetStatus.get_status_lbl(status)
- if status else None)
+ status_change=status_change
)
# get status if set !
diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py
--- a/kallithea/controllers/pullrequests.py
+++ b/kallithea/controllers/pullrequests.py
@@ -696,7 +696,16 @@
if allowed_to_change_status:
status = request.POST.get('changeset_status')
close_pr = request.POST.get('save_close')
- text = request.POST.get('text', '').strip() or _('No comments.')
+ status_change = (ChangesetStatus.get_status_lbl(status)
+ if status and allowed_to_change_status else None)
+
+ text = request.POST.get('text', '').strip()
+ if not text:
+ if status_change:
+ text = _('(status change only)')
+ else:
+ # comment without text and without status change (e.g. close)
+ text = _('(no comments added)')
if close_pr:
text = _('Closing.') + '\n' + text
@@ -707,8 +716,7 @@
pull_request=pull_request_id,
f_path=request.POST.get('f_path'),
line_no=request.POST.get('line'),
- status_change=(ChangesetStatus.get_status_lbl(status)
- if status and allowed_to_change_status else None),
+ status_change=status_change,
closing_pr=close_pr
)
More information about the kallithea-general
mailing list