Skip to content

Commit

Permalink
Merge pull request #443 from lutzky/master
Browse files Browse the repository at this point in the history
Fix rendering for multi-line commands
  • Loading branch information
wagoodman authored Jul 6, 2023
2 parents 99124ab + ceb9688 commit 32c1c1b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dive/image/layer.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ func (l *Layer) ShortId() string {
return id
}

func (l *Layer) commandPreview() string {
// Layers using heredocs can be multiple lines; rendering relies on
// Layer.String to be a single line.
return strings.Replace(l.Command, "\n", "↵", -1)
}

func (l *Layer) String() string {
if l.Index == 0 {
return fmt.Sprintf(LayerFormat,
Expand All @@ -41,5 +47,5 @@ func (l *Layer) String() string {
}
return fmt.Sprintf(LayerFormat,
humanize.Bytes(l.Size),
strings.Split(l.Command, "\n")[0])
l.commandPreview())
}

0 comments on commit 32c1c1b

Please sign in to comment.