Skip to content

Commit

Permalink
show: Mark updated comments
Browse files Browse the repository at this point in the history
Currently updated comments look like other comments.  It is useful to
note that a comment has been updated.

Update 'issue show' and 'mr show' to show the updated comment date and
output a message indicated that the comment was updated.

[Note: gitlab sets the note's UpdatedAt equal to CreatedAt at the time
of creation so it is okay to make the UpdateAt to CreatedAt comparison
and only use UpdatedAt in the output.]

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
  • Loading branch information
prarit committed Aug 21, 2020
1 parent d74937a commit 690015e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion cmd/issue_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ func printDiscussions(discussions []*gitlab.Discussion) {

indentHeader, indentNote := "", ""
commented := "commented"
if ! time.Time(*note.CreatedAt).Equal(time.Time(*note.UpdatedAt)) {
commented = "updated comment"
}

if !discussion.IndividualNote {
indentNote = " "
Expand All @@ -140,7 +143,7 @@ func printDiscussions(discussions []*gitlab.Discussion) {
%s%s
`,
indentHeader,
indentHeader, note.Author.Username, commented, time.Time(*note.CreatedAt).String(),
indentHeader, note.Author.Username, commented, time.Time(*note.UpdatedAt).String(),
indentNote, note.Body)
}
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/mr_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ func printMRDiscussions(discussions []*gitlab.Discussion) {

indentHeader, indentNote := "", ""
commented := "commented"
if ! time.Time(*note.CreatedAt).Equal(time.Time(*note.UpdatedAt)) {
commented = "updated comment"
}

if !discussion.IndividualNote {
indentNote = " "
Expand All @@ -130,7 +133,7 @@ func printMRDiscussions(discussions []*gitlab.Discussion) {
%s%s
`,
indentHeader,
indentHeader, note.Author.Username, commented, time.Time(*note.CreatedAt).String(),
indentHeader, note.Author.Username, commented, time.Time(*note.UpdatedAt).String(),
indentNote, note.Body)
}
}
Expand Down

0 comments on commit 690015e

Please sign in to comment.