mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-23 22:24:51 +02:00
support reverting merge commits
This commit is contained in:
@@ -87,6 +87,14 @@ func TruncateWithEllipsis(str string, limit int) string {
|
||||
return str[0:remainingLength] + "..."
|
||||
}
|
||||
|
||||
func SafeTruncate(str string, limit int) string {
|
||||
if len(str) > limit {
|
||||
return str[0:limit]
|
||||
} else {
|
||||
return str
|
||||
}
|
||||
}
|
||||
|
||||
func FindStringSubmatch(str string, regexpStr string) (bool, []string) {
|
||||
re := regexp.MustCompile(regexpStr)
|
||||
match := re.FindStringSubmatch(str)
|
||||
|
||||
@@ -47,3 +47,43 @@ func TestAsJson(t *testing.T) {
|
||||
// no idea why this is returning empty hashes but it's works in the app ¯\_(ツ)_/¯
|
||||
assert.EqualValues(t, "{}", output)
|
||||
}
|
||||
|
||||
func TestSafeTruncate(t *testing.T) {
|
||||
type scenario struct {
|
||||
str string
|
||||
limit int
|
||||
expected string
|
||||
}
|
||||
|
||||
scenarios := []scenario{
|
||||
{
|
||||
str: "",
|
||||
limit: 0,
|
||||
expected: "",
|
||||
},
|
||||
{
|
||||
str: "12345",
|
||||
limit: 3,
|
||||
expected: "123",
|
||||
},
|
||||
{
|
||||
str: "12345",
|
||||
limit: 4,
|
||||
expected: "1234",
|
||||
},
|
||||
{
|
||||
str: "12345",
|
||||
limit: 5,
|
||||
expected: "12345",
|
||||
},
|
||||
{
|
||||
str: "12345",
|
||||
limit: 6,
|
||||
expected: "12345",
|
||||
},
|
||||
}
|
||||
|
||||
for _, s := range scenarios {
|
||||
assert.EqualValues(t, s.expected, SafeTruncate(s.str, s.limit))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user