mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-03 00:57:52 +02:00
Fix warning QF1004: could use strings.ReplaceAll instead
This commit is contained in:
@ -16,16 +16,16 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var commitsOutput = strings.Replace(`0eea75e8c631fba6b58135697835d58ba4c18dbc|1640826609|Jesse Duffield|jessedduffield@gmail.com|HEAD -> better-tests|b21997d6b4cbdf84b149|>|better typing for rebase mode
|
var commitsOutput = strings.ReplaceAll(`0eea75e8c631fba6b58135697835d58ba4c18dbc|1640826609|Jesse Duffield|jessedduffield@gmail.com|HEAD -> better-tests|b21997d6b4cbdf84b149|>|better typing for rebase mode
|
||||||
b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164|1640824515|Jesse Duffield|jessedduffield@gmail.com|origin/better-tests|e94e8fc5b6fab4cb755f|>|fix logging
|
b21997d6b4cbdf84b149d8e6a2c4d06a8e9ec164|1640824515|Jesse Duffield|jessedduffield@gmail.com|origin/better-tests|e94e8fc5b6fab4cb755f|>|fix logging
|
||||||
e94e8fc5b6fab4cb755f29f1bdb3ee5e001df35c|1640823749|Jesse Duffield|jessedduffield@gmail.com|tag: 123, tag: 456|d8084cd558925eb7c9c3|>|refactor
|
e94e8fc5b6fab4cb755f29f1bdb3ee5e001df35c|1640823749|Jesse Duffield|jessedduffield@gmail.com|tag: 123, tag: 456|d8084cd558925eb7c9c3|>|refactor
|
||||||
d8084cd558925eb7c9c38afeed5725c21653ab90|1640821426|Jesse Duffield|jessedduffield@gmail.com||65f910ebd85283b5cce9|>|WIP
|
d8084cd558925eb7c9c38afeed5725c21653ab90|1640821426|Jesse Duffield|jessedduffield@gmail.com||65f910ebd85283b5cce9|>|WIP
|
||||||
65f910ebd85283b5cce9bf67d03d3f1a9ea3813a|1640821275|Jesse Duffield|jessedduffield@gmail.com||26c07b1ab33860a1a759|>|WIP
|
65f910ebd85283b5cce9bf67d03d3f1a9ea3813a|1640821275|Jesse Duffield|jessedduffield@gmail.com||26c07b1ab33860a1a759|>|WIP
|
||||||
26c07b1ab33860a1a7591a0638f9925ccf497ffa|1640750752|Jesse Duffield|jessedduffield@gmail.com||3d4470a6c072208722e5|>|WIP
|
26c07b1ab33860a1a7591a0638f9925ccf497ffa|1640750752|Jesse Duffield|jessedduffield@gmail.com||3d4470a6c072208722e5|>|WIP
|
||||||
3d4470a6c072208722e5ae9a54bcb9634959a1c5|1640748818|Jesse Duffield|jessedduffield@gmail.com||053a66a7be3da43aacdc|>|WIP
|
3d4470a6c072208722e5ae9a54bcb9634959a1c5|1640748818|Jesse Duffield|jessedduffield@gmail.com||053a66a7be3da43aacdc|>|WIP
|
||||||
053a66a7be3da43aacdc7aa78e1fe757b82c4dd2|1640739815|Jesse Duffield|jessedduffield@gmail.com||985fe482e806b172aea4|>|refactoring the config struct`, "|", "\x00", -1)
|
053a66a7be3da43aacdc7aa78e1fe757b82c4dd2|1640739815|Jesse Duffield|jessedduffield@gmail.com||985fe482e806b172aea4|>|refactoring the config struct`, "|", "\x00")
|
||||||
|
|
||||||
var singleCommitOutput = strings.Replace(`0eea75e8c631fba6b58135697835d58ba4c18dbc|1640826609|Jesse Duffield|jessedduffield@gmail.com|HEAD -> better-tests|b21997d6b4cbdf84b149|>|better typing for rebase mode`, "|", "\x00", -1)
|
var singleCommitOutput = strings.ReplaceAll(`0eea75e8c631fba6b58135697835d58ba4c18dbc|1640826609|Jesse Duffield|jessedduffield@gmail.com|HEAD -> better-tests|b21997d6b4cbdf84b149|>|better typing for rebase mode`, "|", "\x00")
|
||||||
|
|
||||||
func TestGetCommits(t *testing.T) {
|
func TestGetCommits(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
|
@ -14,12 +14,12 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
var reflogOutput = strings.Replace(`c3c4b66b64c97ffeecde|1643150483|checkout: moving from A to B|51baa8c1
|
var reflogOutput = strings.ReplaceAll(`c3c4b66b64c97ffeecde|1643150483|checkout: moving from A to B|51baa8c1
|
||||||
c3c4b66b64c97ffeecde|1643150483|checkout: moving from B to A|51baa8c1
|
c3c4b66b64c97ffeecde|1643150483|checkout: moving from B to A|51baa8c1
|
||||||
c3c4b66b64c97ffeecde|1643150483|checkout: moving from A to B|51baa8c1
|
c3c4b66b64c97ffeecde|1643150483|checkout: moving from A to B|51baa8c1
|
||||||
c3c4b66b64c97ffeecde|1643150483|checkout: moving from master to A|51baa8c1
|
c3c4b66b64c97ffeecde|1643150483|checkout: moving from master to A|51baa8c1
|
||||||
f4ddf2f0d4be4ccc7efa|1643149435|checkout: moving from A to master|51baa8c1
|
f4ddf2f0d4be4ccc7efa|1643149435|checkout: moving from A to master|51baa8c1
|
||||||
`, "|", "\x00", -1)
|
`, "|", "\x00")
|
||||||
|
|
||||||
func TestGetReflogCommits(t *testing.T) {
|
func TestGetReflogCommits(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
|
@ -283,7 +283,7 @@ func PrepareForChildren(cmd *exec.Cmd) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *OSCommand) CopyToClipboard(str string) error {
|
func (c *OSCommand) CopyToClipboard(str string) error {
|
||||||
escaped := strings.Replace(str, "\n", "\\n", -1)
|
escaped := strings.ReplaceAll(str, "\n", "\\n")
|
||||||
truncated := utils.TruncateWithEllipsis(escaped, 40)
|
truncated := utils.TruncateWithEllipsis(escaped, 40)
|
||||||
|
|
||||||
msg := utils.ResolvePlaceholderString(
|
msg := utils.ResolvePlaceholderString(
|
||||||
|
@ -48,7 +48,7 @@ func (gui *Gui) LogCommand(cmdStr string, commandLine bool) {
|
|||||||
textStyle = style.FgMagenta
|
textStyle = style.FgMagenta
|
||||||
}
|
}
|
||||||
gui.GuiLog = append(gui.GuiLog, cmdStr)
|
gui.GuiLog = append(gui.GuiLog, cmdStr)
|
||||||
indentedCmdStr := " " + strings.Replace(cmdStr, "\n", "\n ", -1)
|
indentedCmdStr := " " + strings.ReplaceAll(cmdStr, "\n", "\n ")
|
||||||
fmt.Fprint(gui.Views.Extras, "\n"+textStyle.Sprint(indentedCmdStr))
|
fmt.Fprint(gui.Views.Extras, "\n"+textStyle.Sprint(indentedCmdStr))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,7 +563,7 @@ func (self *RefsHelper) CanMoveCommitsToNewBranch() *types.DisabledReason {
|
|||||||
// SanitizedBranchName will remove all spaces in favor of a dash "-" to meet
|
// SanitizedBranchName will remove all spaces in favor of a dash "-" to meet
|
||||||
// git's branch naming requirement.
|
// git's branch naming requirement.
|
||||||
func SanitizedBranchName(input string) string {
|
func SanitizedBranchName(input string) string {
|
||||||
return strings.Replace(input, " ", "-", -1)
|
return strings.ReplaceAll(input, " ", "-")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the given branch name is a remote branch, and returns the name of
|
// Checks if the given branch name is a remote branch, and returns the name of
|
||||||
|
@ -185,7 +185,7 @@ func (gui *Gui) handleCopySelectedSideContextItemToClipboardWithTruncation(maxWi
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
truncatedItemId := utils.TruncateWithEllipsis(strings.Replace(itemId, "\n", " ", -1), 50)
|
truncatedItemId := utils.TruncateWithEllipsis(strings.ReplaceAll(itemId, "\n", " "), 50)
|
||||||
|
|
||||||
gui.c.Toast(fmt.Sprintf("'%s' %s", truncatedItemId, gui.c.Tr.CopiedToClipboard))
|
gui.c.Toast(fmt.Sprintf("'%s' %s", truncatedItemId, gui.c.Tr.CopiedToClipboard))
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
// currently we are also stripping \r's which may have adverse effects for
|
// currently we are also stripping \r's which may have adverse effects for
|
||||||
// windows users (but no issues have been raised yet)
|
// windows users (but no issues have been raised yet)
|
||||||
func SplitLines(multilineString string) []string {
|
func SplitLines(multilineString string) []string {
|
||||||
multilineString = strings.Replace(multilineString, "\r", "", -1)
|
multilineString = strings.ReplaceAll(multilineString, "\r", "")
|
||||||
if multilineString == "" || multilineString == "\n" {
|
if multilineString == "" || multilineString == "\n" {
|
||||||
return make([]string, 0)
|
return make([]string, 0)
|
||||||
}
|
}
|
||||||
@ -32,8 +32,8 @@ func SplitNul(str string) []string {
|
|||||||
|
|
||||||
// NormalizeLinefeeds - Removes all Windows and Mac style line feeds
|
// NormalizeLinefeeds - Removes all Windows and Mac style line feeds
|
||||||
func NormalizeLinefeeds(str string) string {
|
func NormalizeLinefeeds(str string) string {
|
||||||
str = strings.Replace(str, "\r\n", "\n", -1)
|
str = strings.ReplaceAll(str, "\r\n", "\n")
|
||||||
str = strings.Replace(str, "\r", "", -1)
|
str = strings.ReplaceAll(str, "\r", "")
|
||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user