Skip to content

Commit

Permalink
show: Add system note output
Browse files Browse the repository at this point in the history
The information in the system notes is important.  For example, changing
a merge request description will generate a system note.  Engineers find
this useful in the WebUI and it is easy to show in 'lab mr show' or
'lab issue show'.

System notes cannot have replies so there is no reason to output the
note ID.  Instead, preface system notes with an asterisk '*'.

This change adds lines like, for example,

     * prarit changed the description at 2020-11-12 20:36:39.425 +0000 UTC

to the lab show commands.

Signed-off-by: Prarit Bhargava <[email protected]>
  • Loading branch information
prarit committed Dec 3, 2020
1 parent 4393e71 commit 014a9ec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions cmd/issue_note.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,9 @@ func replyNote(rn string, isMR bool, idNum int, reply int, quote bool, update bo
for _, note := range discussion.Notes {

if note.System {
if note.ID == reply {
fmt.Println("ERROR: Cannot reply to note", note.ID)
}
continue
}

Expand Down
17 changes: 12 additions & 5 deletions cmd/issue_show.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,6 @@ func PrintDiscussions(discussions []*gitlab.Discussion, since string, idstr stri
for _, discussion := range discussions {
for i, note := range discussion.Notes {

// skip system notes
if note.System {
continue
}

indentHeader, indentNote := "", ""
commented := "commented"
if !time.Time(*note.CreatedAt).Equal(time.Time(*note.UpdatedAt)) {
Expand All @@ -316,6 +311,18 @@ func PrintDiscussions(discussions []*gitlab.Discussion, since string, idstr stri

noteBody := strings.Replace(note.Body, "\n", "\n"+indentHeader, -1)
printit := color.New().PrintfFunc()

if note.System {
// system notes are informational messages only
// and cannot have replies. Do not output the
// note.ID
printit(`
* %s %s at %s
`,
note.Author.Username, noteBody, time.Time(*note.UpdatedAt).String())
continue
}

printit(`
%s-----------------------------------`, indentHeader)

Expand Down

0 comments on commit 014a9ec

Please sign in to comment.