mirror of
https://github.com/wagoodman/dive
synced 2026-03-14 14:25:50 +01:00
Fix rendering for multi-line commands
Heredocs can be used to create multi-line commands, which broke rendering. Details about heredocs: https://www.docker.com/blog/introduction-to-heredocs-in-dockerfiles/
This commit is contained in:
parent
2a99dd25fe
commit
ceb9688d92
1 changed files with 7 additions and 1 deletions
|
|
@ -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,
|
||||
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue