fix(migrate): map .ComputerName to .HostName

relates to #1815
This commit is contained in:
Jan De Dobbeleer 2022-02-26 18:59:01 +01:00 committed by Jan De Dobbeleer
parent d7e289b3bf
commit f6d0b9e076
2 changed files with 9 additions and 0 deletions

View file

@ -106,6 +106,7 @@ func (segment *Segment) migrationOne(env environment.Environment) {
segment.migrateTemplate() segment.migrateTemplate()
segment.migrateIconOverride("ssh_icon", "\uf817 ") segment.migrateIconOverride("ssh_icon", "\uf817 ")
template := segment.Properties.GetString(properties.SegmentTemplate, segment.writer.Template()) template := segment.Properties.GetString(properties.SegmentTemplate, segment.writer.Template())
template = strings.ReplaceAll(template, ".ComputerName", ".HostName")
if !segment.Properties.GetBool(properties.Property("display_host"), true) { if !segment.Properties.GetBool(properties.Property("display_host"), true) {
template = strings.ReplaceAll(template, "@{{ .HostName }}", "") template = strings.ReplaceAll(template, "@{{ .HostName }}", "")
} }

View file

@ -310,6 +310,14 @@ func TestSegmentTemplateMigration(t *testing.T) {
"host_color": "#789012", "host_color": "#789012",
}, },
}, },
{
Case: "SESSION - Existing template",
Expected: " {{ .UserName }}@{{ .HostName }} ",
Type: SESSION,
Props: properties.Map{
"template": "{{ .UserName }}@{{ .ComputerName }}",
},
},
} }
for _, tc := range cases { for _, tc := range cases {
segment := &Segment{ segment := &Segment{