mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-03 13:21:56 +02:00
Fix unit tests
This commit is contained in:
parent
b5ff55e538
commit
fb4453c18a
@ -2,7 +2,6 @@ package git_commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"os"
|
||||
@ -67,7 +66,7 @@ func (self *WorktreeCommands) IsCurrentWorktree(path string) bool {
|
||||
func IsCurrentWorktree(path string) bool {
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatalln(err.Error())
|
||||
return false
|
||||
}
|
||||
|
||||
return EqualPath(pwd, path)
|
||||
@ -78,7 +77,8 @@ func (self *WorktreeCommands) IsWorktreePathMissing(path string) bool {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return true
|
||||
}
|
||||
log.Fatalln(fmt.Errorf("failed to check if worktree path `%s` exists\n%w", path, err).Error())
|
||||
self.Log.Errorf("failed to check if worktree path `%s` exists\n%v", path, err)
|
||||
return false
|
||||
}
|
||||
return false
|
||||
}
|
||||
@ -118,7 +118,8 @@ func GetCurrentRepoPath() string {
|
||||
gitPath := filepath.Join(pwd, ".git")
|
||||
gitFileInfo, err := os.Stat(gitPath)
|
||||
if err != nil {
|
||||
log.Fatalln(err.Error())
|
||||
// fallback
|
||||
return currentPath()
|
||||
}
|
||||
|
||||
if gitFileInfo.IsDir() {
|
||||
|
@ -64,7 +64,7 @@ func (self *WorktreeHelper) GetLinkedWorktreeName() string {
|
||||
func (self *WorktreeHelper) IsCurrentWorktree(w *models.Worktree) bool {
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
self.c.Log.Errorf("failed to obtain current working directory: %w", err)
|
||||
self.c.Log.Errorf("failed to obtain current working directory: %v", err)
|
||||
return false
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ func (self *WorktreeHelper) IsWorktreePathMissing(w *models.Worktree) bool {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return true
|
||||
}
|
||||
self.c.Log.Errorf("failed to check if worktree path `%s` exists: %w", w.Path, err)
|
||||
self.c.Log.Errorf("failed to check if worktree path `%s` exists: %v", w.Path, err)
|
||||
return false
|
||||
}
|
||||
return false
|
||||
|
@ -68,12 +68,12 @@ func TestFormatSecondsAgo(t *testing.T) {
|
||||
{
|
||||
name: "six months",
|
||||
args: SECONDS_IN_YEAR / 2,
|
||||
want: "6m",
|
||||
want: "6M",
|
||||
},
|
||||
{
|
||||
name: "almost one year",
|
||||
args: 31535999,
|
||||
want: "11m",
|
||||
want: "11M",
|
||||
},
|
||||
{
|
||||
name: "one year",
|
||||
|
Loading…
x
Reference in New Issue
Block a user