aboutsummaryrefslogtreecommitdiffstats
path: root/termui/show_bug.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-08 16:17:15 +0100
committerMichael Muré <batolettre@gmail.com>2020-02-08 16:17:15 +0100
commit97bc5ccd229b7b438262a84e3c42783b4d4a82af (patch)
tree6e5ef89c8ecce28599e9623d441a18406b2f2f93 /termui/show_bug.go
parent77dc783fcb64adf67d10fc3232c4f06f8e3d5392 (diff)
downloadgit-bug-97bc5ccd229b7b438262a84e3c42783b4d4a82af.tar.gz
various cleanups suggested by golang-ci
Diffstat (limited to 'termui/show_bug.go')
-rw-r--r--termui/show_bug.go54
1 files changed, 21 insertions, 33 deletions
diff --git a/termui/show_bug.go b/termui/show_bug.go
index 6c7163ac..e483117a 100644
--- a/termui/show_bug.go
+++ b/termui/show_bug.go
@@ -238,18 +238,16 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
// TODO: me might skip the rendering of blocks that are outside of the view
// but to do that we need to rework how sb.mainSelectableView is maintained
- switch op.(type) {
+ switch op := op.(type) {
case *bug.CreateTimelineItem:
- create := op.(*bug.CreateTimelineItem)
-
var content string
var lines int
- if create.MessageIsEmpty() {
+ if op.MessageIsEmpty() {
content, lines = text.WrapLeftPadded(emptyMessagePlaceholder(), maxX-1, 4)
} else {
- content, lines = text.WrapLeftPadded(create.Message, maxX-1, 4)
+ content, lines = text.WrapLeftPadded(op.Message, maxX-1, 4)
}
v, err := sb.createOpView(g, viewName, x0, y0, maxX+1, lines, true)
@@ -260,23 +258,21 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
y0 += lines + 2
case *bug.AddCommentTimelineItem:
- comment := op.(*bug.AddCommentTimelineItem)
-
edited := ""
- if comment.Edited() {
+ if op.Edited() {
edited = " (edited)"
}
var message string
- if comment.MessageIsEmpty() {
+ if op.MessageIsEmpty() {
message, _ = text.WrapLeftPadded(emptyMessagePlaceholder(), maxX-1, 4)
} else {
- message, _ = text.WrapLeftPadded(comment.Message, maxX-1, 4)
+ message, _ = text.WrapLeftPadded(op.Message, maxX-1, 4)
}
content := fmt.Sprintf("%s commented on %s%s\n\n%s",
- colors.Magenta(comment.Author.DisplayName()),
- comment.CreatedAt.Time().Format(timeLayout),
+ colors.Magenta(op.Author.DisplayName()),
+ op.CreatedAt.Time().Format(timeLayout),
edited,
message,
)
@@ -290,12 +286,10 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
y0 += lines + 2
case *bug.SetTitleTimelineItem:
- setTitle := op.(*bug.SetTitleTimelineItem)
-
content := fmt.Sprintf("%s changed the title to %s on %s",
- colors.Magenta(setTitle.Author.DisplayName()),
- colors.Bold(setTitle.Title),
- setTitle.UnixTime.Time().Format(timeLayout),
+ colors.Magenta(op.Author.DisplayName()),
+ colors.Bold(op.Title),
+ op.UnixTime.Time().Format(timeLayout),
)
content, lines := text.Wrap(content, maxX)
@@ -307,12 +301,10 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
y0 += lines + 2
case *bug.SetStatusTimelineItem:
- setStatus := op.(*bug.SetStatusTimelineItem)
-
content := fmt.Sprintf("%s %s the bug on %s",
- colors.Magenta(setStatus.Author.DisplayName()),
- colors.Bold(setStatus.Status.Action()),
- setStatus.UnixTime.Time().Format(timeLayout),
+ colors.Magenta(op.Author.DisplayName()),
+ colors.Bold(op.Status.Action()),
+ op.UnixTime.Time().Format(timeLayout),
)
content, lines := text.Wrap(content, maxX)
@@ -324,15 +316,13 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
y0 += lines + 2
case *bug.LabelChangeTimelineItem:
- labelChange := op.(*bug.LabelChangeTimelineItem)
-
var added []string
- for _, label := range labelChange.Added {
+ for _, label := range op.Added {
added = append(added, colors.Bold("\""+label+"\""))
}
var removed []string
- for _, label := range labelChange.Removed {
+ for _, label := range op.Removed {
removed = append(removed, colors.Bold("\""+label+"\""))
}
@@ -359,9 +349,9 @@ func (sb *showBug) renderMain(g *gocui.Gui, mainView *gocui.View) error {
}
content := fmt.Sprintf("%s %s on %s",
- colors.Magenta(labelChange.Author.DisplayName()),
+ colors.Magenta(op.Author.DisplayName()),
action.String(),
- labelChange.UnixTime.Time().Format(timeLayout),
+ op.UnixTime.Time().Format(timeLayout),
)
content, lines := text.Wrap(content, maxX)
@@ -651,13 +641,11 @@ func (sb *showBug) edit(g *gocui.Gui, v *gocui.View) error {
return err
}
- switch op.(type) {
+ switch op := op.(type) {
case *bug.AddCommentTimelineItem:
- message := op.(*bug.AddCommentTimelineItem).Message
- return editCommentWithEditor(sb.bug, op.Id(), message)
+ return editCommentWithEditor(sb.bug, op.Id(), op.Message)
case *bug.CreateTimelineItem:
- preMessage := op.(*bug.CreateTimelineItem).Message
- return editCommentWithEditor(sb.bug, op.Id(), preMessage)
+ return editCommentWithEditor(sb.bug, op.Id(), op.Message)
case *bug.LabelChangeTimelineItem:
return sb.editLabels(g, snap)
}