diff options
Diffstat (limited to 'pkg/commands')
-rw-r--r-- | pkg/commands/git.go | 1 | ||||
-rw-r--r-- | pkg/commands/git_commands/rebase.go | 4 | ||||
-rw-r--r-- | pkg/commands/hosting_service/hosting_service.go | 5 | ||||
-rw-r--r-- | pkg/commands/oscommands/cmd_obj_runner_win.go | 1 | ||||
-rw-r--r-- | pkg/commands/oscommands/fake_cmd_obj_runner.go | 2 | ||||
-rw-r--r-- | pkg/commands/oscommands/os.go | 4 | ||||
-rw-r--r-- | pkg/commands/oscommands/os_test.go | 2 | ||||
-rw-r--r-- | pkg/commands/patch/patch_manager.go | 6 | ||||
-rw-r--r-- | pkg/commands/patch/patch_modifier.go | 6 |
9 files changed, 18 insertions, 13 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go index 3880e0dfc..6c6a3ac7c 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -223,7 +223,6 @@ func setupRepository(openGitRepository func(string) (*gogit.Repository, error), } repository, err := openGitRepository(path) - if err != nil { if strings.Contains(err.Error(), `unquoted '\' must be followed by new line`) { return nil, errors.New(gitConfigParseErrorStr) diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go index c726cad7e..71c8b0e63 100644 --- a/pkg/commands/git_commands/rebase.go +++ b/pkg/commands/git_commands/rebase.go @@ -185,7 +185,7 @@ func (self *RebaseCommands) EditRebaseTodo(index int, action string) error { content[contentIndex] = action + " " + strings.Join(splitLine[1:], " ") result := strings.Join(content, "\n") - return ioutil.WriteFile(fileName, []byte(result), 0644) + return ioutil.WriteFile(fileName, []byte(result), 0o644) } func (self *RebaseCommands) getTodoCommitCount(content []string) int { @@ -215,7 +215,7 @@ func (self *RebaseCommands) MoveTodoDown(index int) error { rearrangedContent = append(rearrangedContent, content[contentIndex+1:]...) result := strings.Join(rearrangedContent, "\n") - return ioutil.WriteFile(fileName, []byte(result), 0644) + return ioutil.WriteFile(fileName, []byte(result), 0o644) } // SquashAllAboveFixupCommits squashes all fixup! commits above the given one diff --git a/pkg/commands/hosting_service/hosting_service.go b/pkg/commands/hosting_service/hosting_service.go index 4a0a49681..b448e3925 100644 --- a/pkg/commands/hosting_service/hosting_service.go +++ b/pkg/commands/hosting_service/hosting_service.go @@ -9,6 +9,8 @@ import ( "github.com/jesseduffield/lazygit/pkg/i18n" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/sirupsen/logrus" + + "golang.org/x/exp/slices" ) // This package is for handling logic specific to a git hosting service like github, gitlab, bitbucket, etc. @@ -94,8 +96,7 @@ func (self *HostingServiceMgr) getCandidateServiceDomains() []ServiceDomain { serviceDefinitionByProvider[serviceDefinition.provider] = serviceDefinition } - var serviceDomains = make([]ServiceDomain, len(defaultServiceDomains)) - copy(serviceDomains, defaultServiceDomains) + serviceDomains := slices.Clone(defaultServiceDomains) if len(self.configServiceDomains) > 0 { for gitDomain, typeAndDomain := range self.configServiceDomains { diff --git a/pkg/commands/oscommands/cmd_obj_runner_win.go b/pkg/commands/oscommands/cmd_obj_runner_win.go index 9e3d1fd02..9a64dfa77 100644 --- a/pkg/commands/oscommands/cmd_obj_runner_win.go +++ b/pkg/commands/oscommands/cmd_obj_runner_win.go @@ -20,6 +20,7 @@ func (b *Buffer) Read(p []byte) (n int, err error) { defer b.m.Unlock() return b.b.Read(p) } + func (b *Buffer) Write(p []byte) (n int, err error) { b.m.Lock() defer b.m.Unlock() diff --git a/pkg/commands/oscommands/fake_cmd_obj_runner.go b/pkg/commands/oscommands/fake_cmd_obj_runner.go index b542bfee3..d06861251 100644 --- a/pkg/commands/oscommands/fake_cmd_obj_runner.go +++ b/pkg/commands/oscommands/fake_cmd_obj_runner.go @@ -21,7 +21,7 @@ type FakeCmdObjRunner struct { var _ ICmdObjRunner = &FakeCmdObjRunner{} -func NewFakeRunner(t *testing.T) *FakeCmdObjRunner { +func NewFakeRunner(t *testing.T) *FakeCmdObjRunner { //nolint:thelper return &FakeCmdObjRunner{t: t} } diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index 1c4f5bf28..f3df3956f 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -103,7 +103,7 @@ func (c *OSCommand) Quote(message string) string { // AppendLineToFile adds a new line in file func (c *OSCommand) AppendLineToFile(filename, line string) error { c.LogCommand(fmt.Sprintf("Appending '%s' to file '%s'", line, filename), false) - f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600) + f, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0o600) if err != nil { return utils.WrapError(err) } @@ -145,7 +145,7 @@ func (c *OSCommand) CreateFileWithContent(path string, content string) error { return err } - if err := ioutil.WriteFile(path, []byte(content), 0644); err != nil { + if err := ioutil.WriteFile(path, []byte(content), 0o644); err != nil { c.Log.Error(err) return utils.WrapError(err) } diff --git a/pkg/commands/oscommands/os_test.go b/pkg/commands/oscommands/os_test.go index efda5a3a1..9c2d9a2a7 100644 --- a/pkg/commands/oscommands/os_test.go +++ b/pkg/commands/oscommands/os_test.go @@ -141,7 +141,7 @@ func TestOSCommandFileType(t *testing.T) { { "testDirectory", func() { - if err := os.Mkdir("testDirectory", 0644); err != nil { + if err := os.Mkdir("testDirectory", 0o644); err != nil { panic(err) } }, diff --git a/pkg/commands/patch/patch_manager.go b/pkg/commands/patch/patch_manager.go index c8e16a7fd..cbdf7b2d4 100644 --- a/pkg/commands/patch/patch_manager.go +++ b/pkg/commands/patch/patch_manager.go @@ -26,8 +26,10 @@ type fileInfo struct { diff string } -type applyPatchFunc func(patch string, flags ...string) error -type loadFileDiffFunc func(from string, to string, reverse bool, filename string, plain bool) (string, error) +type ( + applyPatchFunc func(patch string, flags ...string) error + loadFileDiffFunc func(from string, to string, reverse bool, filename string, plain bool) (string, error) +) // PatchManager manages the building of a patch for a commit to be applied to another commit (or the working tree, or removed from the current commit). We also support building patches from things like stashes, for which there is less flexibility type PatchManager struct { diff --git a/pkg/commands/patch/patch_modifier.go b/pkg/commands/patch/patch_modifier.go index 2109ad1f0..2d060ec18 100644 --- a/pkg/commands/patch/patch_modifier.go +++ b/pkg/commands/patch/patch_modifier.go @@ -8,8 +8,10 @@ import ( "github.com/sirupsen/logrus" ) -var hunkHeaderRegexp = regexp.MustCompile(`(?m)^@@ -(\d+)[^\+]+\+(\d+)[^@]+@@(.*)$`) -var patchHeaderRegexp = regexp.MustCompile(`(?ms)(^diff.*?)^@@`) +var ( + hunkHeaderRegexp = regexp.MustCompile(`(?m)^@@ -(\d+)[^\+]+\+(\d+)[^@]+@@(.*)$`) + patchHeaderRegexp = regexp.MustCompile(`(?ms)(^diff.*?)^@@`) +) func GetHeaderFromDiff(diff string) string { match := patchHeaderRegexp.FindStringSubmatch(diff) |