remove deprecated calls

This commit is contained in:
jiepeng 2022-09-13 18:11:03 +08:00 committed by Jesse Duffield
parent c81333fefe
commit b8900baf1a
21 changed files with 48 additions and 59 deletions

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))