Skip to content

Commit d5289fe

Browse files
author
Gauvain Pocentek
committed
[cli] Fix the non-verbose output of ProjectCommitComment
Closes #433
1 parent b1c6392 commit d5289fe

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

gitlab/v4/cli.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,14 @@ def display_dict(d, padding):
326326
print('%s: %s' % (obj._id_attr.replace('_', '-'), id))
327327
if hasattr(obj, '_short_print_attr'):
328328
value = getattr(obj, obj._short_print_attr)
329-
print('%s: %s' % (obj._short_print_attr, value))
329+
value = value.replace('\r', '').replace('\n', ' ')
330+
# If the attribute is a note (ProjectCommitComment) then we do
331+
# some modifications to fit everything on one line
332+
line = '%s: %s' % (obj._short_print_attr, value)
333+
# ellipsize long lines (comments)
334+
if len(line) > 79:
335+
line = line[:76] + '...'
336+
print(line)
330337

331338
def display_list(self, data, fields, **kwargs):
332339
verbose = kwargs.get('verbose', False)

gitlab/v4/objects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,6 +1411,7 @@ def create(self, data, **kwargs):
14111411

14121412
class ProjectCommitComment(RESTObject):
14131413
_id_attr = None
1414+
_short_print_attr = 'note'
14141415

14151416

14161417
class ProjectCommitCommentManager(ListMixin, CreateMixin, RESTManager):

0 commit comments

Comments
 (0)