Skip to content

Commit

Permalink
[cli] Fix the non-verbose output of ProjectCommitComment
Browse files Browse the repository at this point in the history
Closes #433
  • Loading branch information
Gauvain Pocentek committed Jun 22, 2018
1 parent b1c6392 commit d5289fe
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion gitlab/v4/cli.py
Expand Up @@ -326,7 +326,14 @@ def display_dict(d, padding):
print('%s: %s' % (obj._id_attr.replace('_', '-'), id))
if hasattr(obj, '_short_print_attr'):
value = getattr(obj, obj._short_print_attr)
print('%s: %s' % (obj._short_print_attr, value))
value = value.replace('\r', '').replace('\n', ' ')
# If the attribute is a note (ProjectCommitComment) then we do
# some modifications to fit everything on one line
line = '%s: %s' % (obj._short_print_attr, value)
# ellipsize long lines (comments)
if len(line) > 79:
line = line[:76] + '...'
print(line)

def display_list(self, data, fields, **kwargs):
verbose = kwargs.get('verbose', False)
Expand Down
1 change: 1 addition & 0 deletions gitlab/v4/objects.py
Expand Up @@ -1411,6 +1411,7 @@ def create(self, data, **kwargs):

class ProjectCommitComment(RESTObject):
_id_attr = None
_short_print_attr = 'note'


class ProjectCommitCommentManager(ListMixin, CreateMixin, RESTManager):
Expand Down

0 comments on commit d5289fe

Please sign in to comment.