1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-28 16:02:01 +03:00

Merge pull request #2167 from xiaoliwang/remove_deprecated

This commit is contained in:
Jesse Duffield
2022-09-23 23:01:40 -07:00
committed by GitHub
21 changed files with 47 additions and 57 deletions

View File

@ -1,7 +1,6 @@
package commands
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -68,7 +67,7 @@ func NewGitCommand(
return nil, err
}
dotGitDir, err := findDotGitDir(os.Stat, ioutil.ReadFile)
dotGitDir, err := findDotGitDir(os.Stat, os.ReadFile)
if err != nil {
return nil, err
}

View File

@ -1,7 +1,7 @@
package git_commands
import (
"io/ioutil"
"os"
"strconv"
"github.com/go-errors/errors"
@ -20,7 +20,7 @@ func NewFileCommands(gitCommon *GitCommon) *FileCommands {
// Cat obtains the content of a file
func (self *FileCommands) Cat(fileName string) (string, error) {
buf, err := ioutil.ReadFile(fileName)
buf, err := os.ReadFile(fileName)
if err != nil {
return "", nil
}

View File

@ -2,7 +2,7 @@ package git_commands
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"
@ -202,7 +202,7 @@ func (self *RebaseCommands) AmendTo(sha string) error {
// EditRebaseTodo sets the action at a given index in the git-rebase-todo file
func (self *RebaseCommands) EditRebaseTodo(index int, action string) error {
fileName := filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo")
bytes, err := ioutil.ReadFile(fileName)
bytes, err := os.ReadFile(fileName)
if err != nil {
return err
}
@ -217,7 +217,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), 0o644)
return os.WriteFile(fileName, []byte(result), 0o644)
}
func (self *RebaseCommands) getTodoCommitCount(content []string) int {
@ -234,7 +234,7 @@ func (self *RebaseCommands) getTodoCommitCount(content []string) int {
// MoveTodoDown moves a rebase todo item down by one position
func (self *RebaseCommands) MoveTodoDown(index int) error {
fileName := filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo")
bytes, err := ioutil.ReadFile(fileName)
bytes, err := os.ReadFile(fileName)
if err != nil {
return err
}
@ -247,7 +247,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), 0o644)
return os.WriteFile(fileName, []byte(result), 0o644)
}
// SquashAllAboveFixupCommits squashes all fixup! commits above the given one

View File

@ -2,7 +2,7 @@ package git_commands
import (
"fmt"
"io/ioutil"
"os"
"regexp"
"testing"
@ -432,7 +432,7 @@ func TestWorkingTreeApplyPatch(t *testing.T) {
filename := matches[1]
content, err := ioutil.ReadFile(filename)
content, err := os.ReadFile(filename)
assert.NoError(t, err)
assert.Equal(t, "test", string(content))

View File

@ -3,7 +3,7 @@ package git_config
import (
"bytes"
"fmt"
"io/ioutil"
"io"
"os/exec"
"strings"
"syscall"
@ -38,7 +38,7 @@ import (
func runGitConfigCmd(cmd *exec.Cmd) (string, error) {
var stdout bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = ioutil.Discard
cmd.Stderr = io.Discard
err := cmd.Run()
if exitError, ok := err.(*exec.ExitError); ok {

View File

@ -3,7 +3,6 @@ package loaders
import (
"bytes"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"regexp"
@ -50,7 +49,7 @@ func NewCommitLoader(
cmd: cmd,
getCurrentBranchName: getCurrentBranchName,
getRebaseMode: getRebaseMode,
readFile: ioutil.ReadFile,
readFile: os.ReadFile,
walkFiles: filepath.Walk,
dotGitDir: dotGitDir,
}

View File

@ -2,7 +2,6 @@ package oscommands
import (
"io"
"io/ioutil"
"github.com/sirupsen/logrus"
)
@ -45,7 +44,7 @@ func NewNullGuiIO(log *logrus.Entry) *guiIO {
return &guiIO{
log: log,
logCommandFn: func(string, bool) {},
newCmdWriterFn: func() io.Writer { return ioutil.Discard },
newCmdWriterFn: func() io.Writer { return io.Discard },
promptForCredentialFn: failPromptFn,
}
}

View File

@ -2,7 +2,7 @@ package oscommands
import (
"fmt"
"io/ioutil"
"io"
"os"
"os/exec"
"path/filepath"
@ -151,7 +151,7 @@ func (c *OSCommand) CreateFileWithContent(path string, content string) error {
return err
}
if err := ioutil.WriteFile(path, []byte(content), 0o644); err != nil {
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
c.Log.Error(err)
return utils.WrapError(err)
}
@ -215,7 +215,7 @@ func (c *OSCommand) PipeCommands(commandStrings ...string) error {
c.Log.Error(err)
}
if b, err := ioutil.ReadAll(stderr); err == nil {
if b, err := io.ReadAll(stderr); err == nil {
if len(b) > 0 {
finalErrors = append(finalErrors, string(b))
}

View File

@ -1,7 +1,6 @@
package oscommands
import (
"io/ioutil"
"os"
"path/filepath"
"testing"
@ -149,7 +148,7 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
{
filepath.Join(os.TempDir(), "testFile"),
func(path string) {
if err := ioutil.WriteFile(path, []byte("hello"), 0o600); err != nil {
if err := os.WriteFile(path, []byte("hello"), 0o600); err != nil {
panic(err)
}
},
@ -160,7 +159,7 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
{
filepath.Join(os.TempDir(), "emptyTestFile"),
func(path string) {
if err := ioutil.WriteFile(path, []byte(""), 0o600); err != nil {
if err := os.WriteFile(path, []byte(""), 0o600); err != nil {
panic(err)
}
},
@ -171,7 +170,7 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
{
filepath.Join(os.TempDir(), "testFileWithNewline"),
func(path string) {
if err := ioutil.WriteFile(path, []byte("hello\n"), 0o600); err != nil {
if err := os.WriteFile(path, []byte("hello\n"), 0o600); err != nil {
panic(err)
}
},
@ -187,7 +186,7 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
if err := osCommand.AppendLineToFile(s.path, "world"); err != nil {
panic(err)
}
f, err := ioutil.ReadFile(s.path)
f, err := os.ReadFile(s.path)
if err != nil {
panic(err)
}