mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +02:00
remove deprecated calls
This commit is contained in:
parent
c81333fefe
commit
b8900baf1a
21 changed files with 48 additions and 59 deletions
|
@ -1,7 +1,6 @@
|
||||||
package daemon
|
package daemon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -77,7 +76,7 @@ func (self *rebaseDaemon) Run() error {
|
||||||
self.c.Log.Info("args: ", os.Args)
|
self.c.Log.Info("args: ", os.Args)
|
||||||
|
|
||||||
if strings.HasSuffix(os.Args[1], "git-rebase-todo") {
|
if strings.HasSuffix(os.Args[1], "git-rebase-todo") {
|
||||||
if err := ioutil.WriteFile(os.Args[1], []byte(os.Getenv(RebaseTODOEnvKey)), 0o644); err != nil {
|
if err := os.WriteFile(os.Args[1], []byte(os.Getenv(RebaseTODOEnvKey)), 0o644); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if strings.HasSuffix(os.Args[1], filepath.Join(gitDir(), "COMMIT_EDITMSG")) { // TODO: test
|
} else if strings.HasSuffix(os.Args[1], filepath.Join(gitDir(), "COMMIT_EDITMSG")) { // TODO: test
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ func newLogger(config config.AppConfigurer) *logrus.Entry {
|
||||||
|
|
||||||
func newProductionLogger() *logrus.Logger {
|
func newProductionLogger() *logrus.Logger {
|
||||||
log := logrus.New()
|
log := logrus.New()
|
||||||
log.Out = ioutil.Discard
|
log.Out = io.Discard
|
||||||
log.SetLevel(logrus.ErrorLevel)
|
log.SetLevel(logrus.ErrorLevel)
|
||||||
return log
|
return log
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package cheatsheet
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -60,7 +59,7 @@ func obtainContent(dir string) string {
|
||||||
content := ""
|
content := ""
|
||||||
err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
|
err := filepath.WalkDir(dir, func(path string, d fs.DirEntry, err error) error {
|
||||||
if re.MatchString(path) {
|
if re.MatchString(path) {
|
||||||
bytes, err := ioutil.ReadFile(path)
|
bytes, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error occurred while checking if cheatsheets are up to date: %v", err)
|
log.Fatalf("Error occurred while checking if cheatsheets are up to date: %v", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -68,7 +67,7 @@ func NewGitCommand(
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
dotGitDir, err := findDotGitDir(os.Stat, ioutil.ReadFile)
|
dotGitDir, err := findDotGitDir(os.Stat, os.ReadFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package git_commands
|
package git_commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
|
@ -20,7 +20,7 @@ func NewFileCommands(gitCommon *GitCommon) *FileCommands {
|
||||||
|
|
||||||
// Cat obtains the content of a file
|
// Cat obtains the content of a file
|
||||||
func (self *FileCommands) Cat(fileName string) (string, error) {
|
func (self *FileCommands) Cat(fileName string) (string, error) {
|
||||||
buf, err := ioutil.ReadFile(fileName)
|
buf, err := os.ReadFile(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package git_commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"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
|
// EditRebaseTodo sets the action at a given index in the git-rebase-todo file
|
||||||
func (self *RebaseCommands) EditRebaseTodo(index int, action string) error {
|
func (self *RebaseCommands) EditRebaseTodo(index int, action string) error {
|
||||||
fileName := filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo")
|
fileName := filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo")
|
||||||
bytes, err := ioutil.ReadFile(fileName)
|
bytes, err := os.ReadFile(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ func (self *RebaseCommands) EditRebaseTodo(index int, action string) error {
|
||||||
content[contentIndex] = action + " " + strings.Join(splitLine[1:], " ")
|
content[contentIndex] = action + " " + strings.Join(splitLine[1:], " ")
|
||||||
result := strings.Join(content, "\n")
|
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 {
|
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
|
// MoveTodoDown moves a rebase todo item down by one position
|
||||||
func (self *RebaseCommands) MoveTodoDown(index int) error {
|
func (self *RebaseCommands) MoveTodoDown(index int) error {
|
||||||
fileName := filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo")
|
fileName := filepath.Join(self.dotGitDir, "rebase-merge/git-rebase-todo")
|
||||||
bytes, err := ioutil.ReadFile(fileName)
|
bytes, err := os.ReadFile(fileName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ func (self *RebaseCommands) MoveTodoDown(index int) error {
|
||||||
rearrangedContent = append(rearrangedContent, content[contentIndex+1:]...)
|
rearrangedContent = append(rearrangedContent, content[contentIndex+1:]...)
|
||||||
result := strings.Join(rearrangedContent, "\n")
|
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
|
// SquashAllAboveFixupCommits squashes all fixup! commits above the given one
|
||||||
|
|
|
@ -2,7 +2,7 @@ package git_commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
@ -432,7 +432,7 @@ func TestWorkingTreeApplyPatch(t *testing.T) {
|
||||||
|
|
||||||
filename := matches[1]
|
filename := matches[1]
|
||||||
|
|
||||||
content, err := ioutil.ReadFile(filename)
|
content, err := os.ReadFile(filename)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, "test", string(content))
|
assert.Equal(t, "test", string(content))
|
||||||
|
|
|
@ -3,7 +3,7 @@ package git_config
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
@ -38,7 +38,7 @@ import (
|
||||||
func runGitConfigCmd(cmd *exec.Cmd) (string, error) {
|
func runGitConfigCmd(cmd *exec.Cmd) (string, error) {
|
||||||
var stdout bytes.Buffer
|
var stdout bytes.Buffer
|
||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
cmd.Stderr = ioutil.Discard
|
cmd.Stderr = io.Discard
|
||||||
|
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
if exitError, ok := err.(*exec.ExitError); ok {
|
if exitError, ok := err.(*exec.ExitError); ok {
|
||||||
|
|
|
@ -3,7 +3,6 @@ package loaders
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
@ -50,7 +49,7 @@ func NewCommitLoader(
|
||||||
cmd: cmd,
|
cmd: cmd,
|
||||||
getCurrentBranchName: getCurrentBranchName,
|
getCurrentBranchName: getCurrentBranchName,
|
||||||
getRebaseMode: getRebaseMode,
|
getRebaseMode: getRebaseMode,
|
||||||
readFile: ioutil.ReadFile,
|
readFile: os.ReadFile,
|
||||||
walkFiles: filepath.Walk,
|
walkFiles: filepath.Walk,
|
||||||
dotGitDir: dotGitDir,
|
dotGitDir: dotGitDir,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package oscommands
|
package oscommands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
|
||||||
"io/ioutil"
|
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
// this struct captures some IO stuff
|
// this struct captures some IO stuff
|
||||||
|
@ -45,7 +43,7 @@ func NewNullGuiIO(log *logrus.Entry) *guiIO {
|
||||||
return &guiIO{
|
return &guiIO{
|
||||||
log: log,
|
log: log,
|
||||||
logCommandFn: func(string, bool) {},
|
logCommandFn: func(string, bool) {},
|
||||||
newCmdWriterFn: func() io.Writer { return ioutil.Discard },
|
newCmdWriterFn: func() io.Writer { return io.Discard },
|
||||||
promptForCredentialFn: failPromptFn,
|
promptForCredentialFn: failPromptFn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package oscommands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -151,7 +151,7 @@ func (c *OSCommand) CreateFileWithContent(path string, content string) error {
|
||||||
return err
|
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)
|
c.Log.Error(err)
|
||||||
return utils.WrapError(err)
|
return utils.WrapError(err)
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ func (c *OSCommand) PipeCommands(commandStrings ...string) error {
|
||||||
c.Log.Error(err)
|
c.Log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if b, err := ioutil.ReadAll(stderr); err == nil {
|
if b, err := io.ReadAll(stderr); err == nil {
|
||||||
if len(b) > 0 {
|
if len(b) > 0 {
|
||||||
finalErrors = append(finalErrors, string(b))
|
finalErrors = append(finalErrors, string(b))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package oscommands
|
package oscommands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -149,7 +148,7 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
|
||||||
{
|
{
|
||||||
filepath.Join(os.TempDir(), "testFile"),
|
filepath.Join(os.TempDir(), "testFile"),
|
||||||
func(path string) {
|
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)
|
panic(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -160,7 +159,7 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
|
||||||
{
|
{
|
||||||
filepath.Join(os.TempDir(), "emptyTestFile"),
|
filepath.Join(os.TempDir(), "emptyTestFile"),
|
||||||
func(path string) {
|
func(path string) {
|
||||||
if err := ioutil.WriteFile(path, []byte(""), 0o600); err != nil {
|
if err := os.WriteFile(path, []byte(""), 0o600); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -171,7 +170,7 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
|
||||||
{
|
{
|
||||||
filepath.Join(os.TempDir(), "testFileWithNewline"),
|
filepath.Join(os.TempDir(), "testFileWithNewline"),
|
||||||
func(path string) {
|
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)
|
panic(err)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -187,7 +186,7 @@ func TestOSCommandAppendLineToFile(t *testing.T) {
|
||||||
if err := osCommand.AppendLineToFile(s.path, "world"); err != nil {
|
if err := osCommand.AppendLineToFile(s.path, "world"); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
f, err := ioutil.ReadFile(s.path)
|
f, err := os.ReadFile(s.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -152,7 +151,7 @@ func loadUserConfig(configFiles []string, base *UserConfig) (*UserConfig, error)
|
||||||
file.Close()
|
file.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
content, err := ioutil.ReadFile(path)
|
content, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -243,7 +242,7 @@ func (c *AppConfig) SaveAppState() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(filepath, marshalledAppState, 0o644)
|
err = os.WriteFile(filepath, marshalledAppState, 0o644)
|
||||||
if err != nil && os.IsPermission(err) {
|
if err != nil && os.IsPermission(err) {
|
||||||
// apparently when people have read-only permissions they prefer us to fail silently
|
// apparently when people have read-only permissions they prefer us to fail silently
|
||||||
return nil
|
return nil
|
||||||
|
@ -263,7 +262,7 @@ func loadAppState() (*AppState, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
appStateBytes, err := ioutil.ReadFile(filepath)
|
appStateBytes, err := os.ReadFile(filepath)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package controllers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
|
@ -192,7 +193,7 @@ func (self *MergeConflictsController) HandleUndo() error {
|
||||||
|
|
||||||
self.c.LogAction("Restoring file to previous state")
|
self.c.LogAction("Restoring file to previous state")
|
||||||
self.c.LogCommand("Undoing last conflict resolution", false)
|
self.c.LogCommand("Undoing last conflict resolution", false)
|
||||||
if err := ioutil.WriteFile(state.GetPath(), []byte(state.GetContent()), 0o644); err != nil {
|
if err := ioutil.os(state.GetPath(), []byte(state.GetContent()), 0o644); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,7 +281,7 @@ func (self *MergeConflictsController) resolveConflict(selection mergeconflicts.S
|
||||||
self.c.LogAction("Resolve merge conflict")
|
self.c.LogAction("Resolve merge conflict")
|
||||||
self.c.LogCommand(logStr, false)
|
self.c.LogCommand(logStr, false)
|
||||||
state.PushContent(content)
|
state.PushContent(content)
|
||||||
return true, ioutil.WriteFile(state.GetPath(), []byte(content), 0o644)
|
return true, os.WriteFile(state.GetPath(), []byte(content), 0o644)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MergeConflictsController) onLastConflictResolved() error {
|
func (self *MergeConflictsController) onLastConflictResolved() error {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -656,8 +656,8 @@ func (gui *Gui) runSubprocess(cmdObj oscommands.ICmdObj) error { //nolint:unpara
|
||||||
|
|
||||||
err := subprocess.Run()
|
err := subprocess.Run()
|
||||||
|
|
||||||
subprocess.Stdout = ioutil.Discard
|
subprocess.Stdout = io.Discard
|
||||||
subprocess.Stderr = ioutil.Discard
|
subprocess.Stderr = io.Discard
|
||||||
subprocess.Stdin = nil
|
subprocess.Stdin = nil
|
||||||
|
|
||||||
if gui.Config.GetUserConfig().PromptToReturnFromSubprocess {
|
if gui.Config.GetUserConfig().PromptToReturnFromSubprocess {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -20,7 +19,7 @@ import (
|
||||||
|
|
||||||
func (gui *Gui) getCurrentBranch(path string) string {
|
func (gui *Gui) getCurrentBranch(path string) string {
|
||||||
readHeadFile := func(path string) (string, error) {
|
readHeadFile := func(path string) (string, error) {
|
||||||
headFile, err := ioutil.ReadFile(filepath.Join(path, "HEAD"))
|
headFile, err := os.ReadFile(filepath.Join(path, "HEAD"))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
content := strings.TrimSpace(string(headFile))
|
content := strings.TrimSpace(string(headFile))
|
||||||
refsPrefix := "ref: refs/heads/"
|
refsPrefix := "ref: refs/heads/"
|
||||||
|
@ -47,7 +46,7 @@ func (gui *Gui) getCurrentBranch(path string) string {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// worktree
|
// worktree
|
||||||
if worktreeGitDir, err := ioutil.ReadFile(gitDirPath); err == nil {
|
if worktreeGitDir, err := os.ReadFile(gitDirPath); err == nil {
|
||||||
content := strings.TrimSpace(string(worktreeGitDir))
|
content := strings.TrimSpace(string(worktreeGitDir))
|
||||||
worktreePath := strings.TrimPrefix(content, "gitdir: ")
|
worktreePath := strings.TrimPrefix(content, "gitdir: ")
|
||||||
if branch, err := readHeadFile(worktreePath); err == nil {
|
if branch, err := readHeadFile(worktreePath); err == nil {
|
||||||
|
|
|
@ -2,7 +2,6 @@ package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -93,7 +92,7 @@ func GetRecordingSpeed() float64 {
|
||||||
func LoadRecording() (*gocui.Recording, error) {
|
func LoadRecording() (*gocui.Recording, error) {
|
||||||
path := os.Getenv("REPLAY_EVENTS_FROM")
|
path := os.Getenv("REPLAY_EVENTS_FROM")
|
||||||
|
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -120,5 +119,5 @@ func SaveRecording(recording *gocui.Recording) error {
|
||||||
|
|
||||||
path := recordEventsTo()
|
path := recordEventsTo()
|
||||||
|
|
||||||
return ioutil.WriteFile(path, jsonEvents, 0o600)
|
return os.WriteFile(path, jsonEvents, 0o600)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package components
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
@ -38,7 +37,7 @@ func (s *Shell) RunCommand(cmdStr string) *Shell {
|
||||||
|
|
||||||
func (s *Shell) CreateFile(path string, content string) *Shell {
|
func (s *Shell) CreateFile(path string, content string) *Shell {
|
||||||
fullPath := filepath.Join(s.dir, path)
|
fullPath := filepath.Join(s.dir, path)
|
||||||
err := ioutil.WriteFile(fullPath, []byte(content), 0o644)
|
err := os.WriteFile(fullPath, []byte(content), 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("error creating file: %s\n%s", fullPath, err))
|
panic(fmt.Sprintf("error creating file: %s\n%s", fullPath, err))
|
||||||
}
|
}
|
||||||
|
@ -48,7 +47,7 @@ func (s *Shell) CreateFile(path string, content string) *Shell {
|
||||||
|
|
||||||
func (s *Shell) UpdateFile(path string, content string) *Shell {
|
func (s *Shell) UpdateFile(path string, content string) *Shell {
|
||||||
fullPath := filepath.Join(s.dir, path)
|
fullPath := filepath.Join(s.dir, path)
|
||||||
err := ioutil.WriteFile(fullPath, []byte(content), 0o644)
|
err := os.WriteFile(fullPath, []byte(content), 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Sprintf("error updating file: %s\n%s", fullPath, err))
|
panic(fmt.Sprintf("error updating file: %s\n%s", fullPath, err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ func (self *Snapshotter) compareSnapshots() error {
|
||||||
|
|
||||||
if expectedRepo != actualRepo {
|
if expectedRepo != actualRepo {
|
||||||
// get the log file and print it
|
// get the log file and print it
|
||||||
bytes, err := ioutil.ReadFile(filepath.Join(self.paths.Config(), "development.log"))
|
bytes, err := os.ReadFile(filepath.Join(self.paths.Config(), "development.log"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -250,7 +250,7 @@ func generateSnapshot(dir string) (string, error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes, err := ioutil.ReadFile(path)
|
bytes, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ func RunTests(
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the log file and print it
|
// get the log file and print it
|
||||||
bytes, err := ioutil.ReadFile(filepath.Join(configDir, "development.log"))
|
bytes, err := os.ReadFile(filepath.Join(configDir, "development.log"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -324,7 +324,7 @@ func LoadTests(testDir string) ([]*IntegrationTest, error) {
|
||||||
tests := make([]*IntegrationTest, len(paths))
|
tests := make([]*IntegrationTest, len(paths))
|
||||||
|
|
||||||
for i, path := range paths {
|
for i, path := range paths {
|
||||||
data, err := ioutil.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ func generateSnapshot(dir string) (string, error) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes, err := ioutil.ReadFile(path)
|
bytes, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
"github.com/jesseduffield/lazygit/pkg/common"
|
||||||
"github.com/jesseduffield/lazygit/pkg/config"
|
"github.com/jesseduffield/lazygit/pkg/config"
|
||||||
"github.com/jesseduffield/lazygit/pkg/i18n"
|
"github.com/jesseduffield/lazygit/pkg/i18n"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDummyLog creates a new dummy Log for testing
|
// NewDummyLog creates a new dummy Log for testing
|
||||||
func NewDummyLog() *logrus.Entry {
|
func NewDummyLog() *logrus.Entry {
|
||||||
log := logrus.New()
|
log := logrus.New()
|
||||||
log.Out = ioutil.Discard
|
log.Out = io.Discard
|
||||||
return log.WithField("test", "test")
|
return log.WithField("test", "test")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue