diff --git a/src/vcs/p4/p4_impl.go b/src/vcs/p4/p4_impl.go index 05bc3e9e..c3d1fb2b 100644 --- a/src/vcs/p4/p4_impl.go +++ b/src/vcs/p4/p4_impl.go @@ -32,8 +32,6 @@ import ( "github.com/murex/tcr/vcs" "github.com/murex/tcr/vcs/shell" "github.com/spf13/afero" - "golang.org/x/text/encoding/charmap" - "golang.org/x/text/transform" "path/filepath" "strconv" "strings" @@ -299,24 +297,12 @@ func buildDescriptionField(attr shell.Attributes, messages ...string) string { var builder strings.Builder _, _ = builder.WriteString("Description=") for _, message := range messages { - _, _ = builder.WriteString(convertLine(attr.Encoding, message)) + _, _ = builder.WriteString(message) _, _ = builder.WriteString(attr.EOL) } return builder.String() } -func convertLine(charMap *charmap.Charmap, message string) string { - if charMap == nil { - // By default, we use UTF-8, which is the default with Go strings - return message - } - var b bytes.Buffer - converter := transform.NewWriter(&b, charMap.NewDecoder()) - _, _ = converter.Write([]byte(message)) - _ = converter.Close() - return b.String() -} - func (p *p4Impl) submitChangeList(cl *changeList) error { if cl == nil { report.PostWarning("Empty changelist!") diff --git a/src/vcs/p4/p4_impl_test.go b/src/vcs/p4/p4_impl_test.go index ce9baed4..9693dd59 100644 --- a/src/vcs/p4/p4_impl_test.go +++ b/src/vcs/p4/p4_impl_test.go @@ -24,12 +24,10 @@ package p4 import ( "errors" - "fmt" "github.com/murex/tcr/vcs" "github.com/murex/tcr/vcs/shell" "github.com/spf13/afero" "github.com/stretchr/testify/assert" - "golang.org/x/text/encoding/charmap" "path/filepath" "testing" ) @@ -99,26 +97,6 @@ func Test_p4_get_remote_name_is_always_empty(t *testing.T) { assert.Equal(t, "", p.GetRemoteName()) } -func Test_convert_line(t *testing.T) { - tests := []struct { - desc string - input rune - encoding *charmap.Charmap - expected string - }{ - {"UTC-8 smiley", '🙂', nil, "f09f9982"}, - {"ISO8859-1 smiley", '🙂', charmap.ISO8859_1, "c3b0c29fc299c282"}, - {"WINDOWS-1252 smiley", '🙂', charmap.Windows1252, "c3b0c5b8e284a2e2809a"}, - } - - for _, test := range tests { - t.Run(test.desc, func(t *testing.T) { - //t.Logf("%x - %x", test.input, convertLine(test.encoding, string(test.input))) - assert.Equal(t, test.expected, fmt.Sprintf("%x", convertLine(test.encoding, string(test.input)))) - }) - } -} - func Test_p4_diff(t *testing.T) { testFlags := []struct { desc string diff --git a/src/vcs/shell/shell.go b/src/vcs/shell/shell.go index 968fcce9..5527d111 100644 --- a/src/vcs/shell/shell.go +++ b/src/vcs/shell/shell.go @@ -22,13 +22,10 @@ SOFTWARE. package shell -import "golang.org/x/text/encoding/charmap" - // Attributes contain shell-specific attributes allowing to tune behavior // when interacting with a shell command type Attributes struct { - Encoding *charmap.Charmap - EOL string + EOL string } // GetAttributes Returns shell-specific attributes diff --git a/src/vcs/shell/shell_unix.go b/src/vcs/shell/shell_unix.go index 84974072..dc5acf1c 100644 --- a/src/vcs/shell/shell_unix.go +++ b/src/vcs/shell/shell_unix.go @@ -27,7 +27,6 @@ package shell // osShellAttributes returns shell attributes associated to the underlying operating system func osShellAttributes() Attributes { return Attributes{ - Encoding: nil, - EOL: "\n", + EOL: "\n", } } diff --git a/src/vcs/shell/shell_unix_test.go b/src/vcs/shell/shell_unix_test.go index dfa861f8..36fb959c 100644 --- a/src/vcs/shell/shell_unix_test.go +++ b/src/vcs/shell/shell_unix_test.go @@ -29,12 +29,6 @@ import ( "testing" ) -func Test_unix_shell_encoding(t *testing.T) { - // nil means that we use Go's default string encoding (UTF-8) - // e.g. no conversion is required - assert.Zero(t, GetAttributes().Encoding) -} - func Test_unix_shell_end_of_line(t *testing.T) { assert.Equal(t, "\n", GetAttributes().EOL) } diff --git a/src/vcs/shell/shell_windows.go b/src/vcs/shell/shell_windows.go index f8a1aabb..e31f3492 100644 --- a/src/vcs/shell/shell_windows.go +++ b/src/vcs/shell/shell_windows.go @@ -22,12 +22,9 @@ SOFTWARE. package shell -import "golang.org/x/text/encoding/charmap" - // osShellAttributes returns shell attributes associated to the underlying operating system func osShellAttributes() Attributes { return Attributes{ - Encoding: charmap.Windows1252, - EOL: "\r\n", + EOL: "\r\n", } } diff --git a/src/vcs/shell/shell_windows_test.go b/src/vcs/shell/shell_windows_test.go index f092d6be..372d2e07 100644 --- a/src/vcs/shell/shell_windows_test.go +++ b/src/vcs/shell/shell_windows_test.go @@ -24,16 +24,9 @@ package shell import ( "github.com/stretchr/testify/assert" - "golang.org/x/text/encoding/charmap" "testing" ) -func Test_windows_shell_encoding(t *testing.T) { - // Windows1252 works for Western character set. We may need a more sophisticated - // approach if we want to cover users with other character sets. - assert.Equal(t, charmap.Windows1252, GetAttributes().Encoding) -} - func Test_windows_shell_end_of_line(t *testing.T) { assert.Equal(t, "\r\n", GetAttributes().EOL) }