mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 04:45:47 +02:00
Address PR comments
This commit is contained in:
parent
1ce9a87544
commit
db02c13bf6
7 changed files with 74 additions and 67 deletions
|
@ -1,5 +1,15 @@
|
|||
package git_commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||
)
|
||||
|
||||
type WorktreeCommands struct {
|
||||
*GitCommon
|
||||
}
|
||||
|
@ -21,3 +31,22 @@ func (self *WorktreeCommands) Delete(worktreePath string, force bool) error {
|
|||
|
||||
return self.cmd.New(cmdArgs).Run()
|
||||
}
|
||||
|
||||
func (self *WorktreeCommands) IsCurrentWorktree(w *models.Worktree) bool {
|
||||
pwd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatalln(err.Error())
|
||||
}
|
||||
|
||||
return pwd == w.Path
|
||||
}
|
||||
|
||||
func (self *WorktreeCommands) IsWorktreePathMissing(w *models.Worktree) bool {
|
||||
if _, err := os.Stat(w.Path); err != nil {
|
||||
if errors.Is(err, fs.ErrNotExist) {
|
||||
return true
|
||||
}
|
||||
log.Fatalln(fmt.Errorf("failed to check if worktree path `%s` exists\n%w", w.Path, err).Error())
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue