mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-17 00:18:05 +02:00
Improve worktree panel
This commit is contained in:
committed by
Jesse Duffield
parent
c679fd1924
commit
54708233ac
@ -1,6 +1,7 @@
|
|||||||
package git_commands
|
package git_commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
@ -46,18 +47,11 @@ func (self *WorktreeLoader) GetWorktrees() ([]*models.Worktree, error) {
|
|||||||
Id: len(worktrees),
|
Id: len(worktrees),
|
||||||
Path: path,
|
Path: path,
|
||||||
}
|
}
|
||||||
|
} else if strings.HasPrefix(splitLine, "branch ") {
|
||||||
|
branch := strings.SplitN(splitLine, " ", 2)[1]
|
||||||
|
currentWorktree.Branch = filepath.Base(branch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
worktree /Users/jbaranick/Source/lazygit
|
|
||||||
HEAD f6d6b5dec0432ffa953611700ab9b1ff0089f948
|
|
||||||
branch refs/heads/worktree_support
|
|
||||||
|
|
||||||
worktree /Users/jbaranick/Source/lazygit/.worktrees/worktree_tests
|
|
||||||
HEAD f6d6b5dec0432ffa953611700ab9b1ff0089f948
|
|
||||||
branch refs/heads/worktree_tests
|
|
||||||
*/
|
|
||||||
|
|
||||||
return worktrees, nil
|
return worktrees, nil
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
type Worktree struct {
|
type Worktree struct {
|
||||||
Id int
|
Id int
|
||||||
Path string
|
Path string
|
||||||
|
Branch string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *Worktree) RefName() string {
|
func (w *Worktree) RefName() string {
|
||||||
|
@ -59,7 +59,15 @@ func (self *WorktreesController) GetOnRenderToMain() func() error {
|
|||||||
if worktree.Missing() {
|
if worktree.Missing() {
|
||||||
missing = style.FgRed.Sprint(" (missing)")
|
missing = style.FgRed.Sprint(" (missing)")
|
||||||
}
|
}
|
||||||
task = types.NewRenderStringTask(fmt.Sprintf("%s\nPath: %s%s", style.FgGreen.Sprint(worktree.Name()), worktree.Path, missing))
|
task = types.NewRenderStringTask(
|
||||||
|
fmt.Sprintf(
|
||||||
|
"Name: %s\nBranch: %s\nPath: %s%s\n",
|
||||||
|
style.FgGreen.Sprint(worktree.Name()),
|
||||||
|
style.FgYellow.Sprint(worktree.Branch),
|
||||||
|
style.FgCyan.Sprint(worktree.Path),
|
||||||
|
missing,
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
return self.c.RenderToMainViews(types.RefreshMainOpts{
|
||||||
|
Reference in New Issue
Block a user