mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-19 12:12:42 +02:00
feat(gui): show commit icons
This commit is contained in:
parent
b07aeda5a6
commit
cb13fe7f46
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/authors"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation/authors"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/graph"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation/graph"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/services/custom_commands"
|
"github.com/jesseduffield/lazygit/pkg/gui/services/custom_commands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||||
@ -479,7 +480,7 @@ func NewGui(
|
|||||||
gui.c = helperCommon
|
gui.c = helperCommon
|
||||||
|
|
||||||
authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors)
|
authors.SetCustomAuthors(gui.UserConfig.Gui.AuthorColors)
|
||||||
presentation.SetShowFileIcon(gui.UserConfig.Gui.ShowIcons)
|
icons.SetIconEnabled(gui.UserConfig.Gui.ShowIcons)
|
||||||
presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors)
|
presentation.SetCustomBranches(gui.UserConfig.Gui.BranchColors)
|
||||||
|
|
||||||
return gui, nil
|
return gui, nil
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/authors"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation/authors"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/presentation/graph"
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation/graph"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/gui/presentation/icons"
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
"github.com/jesseduffield/lazygit/pkg/gui/style"
|
||||||
"github.com/jesseduffield/lazygit/pkg/theme"
|
"github.com/jesseduffield/lazygit/pkg/theme"
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
@ -275,7 +276,10 @@ func displayCommit(
|
|||||||
authorFunc = authors.LongAuthor
|
authorFunc = authors.LongAuthor
|
||||||
}
|
}
|
||||||
|
|
||||||
cols := make([]string, 0, 5)
|
cols := make([]string, 0, 7)
|
||||||
|
if icons.IsIconEnabled() {
|
||||||
|
cols = append(cols, shaColor.Sprint(icons.IconForCommit(commit)))
|
||||||
|
}
|
||||||
cols = append(cols, shaColor.Sprint(commit.ShortSha()))
|
cols = append(cols, shaColor.Sprint(commit.ShortSha()))
|
||||||
cols = append(cols, bisectString)
|
cols = append(cols, bisectString)
|
||||||
if fullDescription {
|
if fullDescription {
|
||||||
|
@ -12,8 +12,6 @@ import (
|
|||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var showFileIcon = false
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
EXPANDED_ARROW = "▼"
|
EXPANDED_ARROW = "▼"
|
||||||
COLLAPSED_ARROW = "►"
|
COLLAPSED_ARROW = "►"
|
||||||
@ -160,7 +158,7 @@ func getFileLine(hasUnstagedChanges bool, hasStagedChanges bool, name string, di
|
|||||||
isSubmodule := file != nil && file.IsSubmodule(submoduleConfigs)
|
isSubmodule := file != nil && file.IsSubmodule(submoduleConfigs)
|
||||||
isDirectory := file == nil
|
isDirectory := file == nil
|
||||||
|
|
||||||
if showFileIcon {
|
if icons.IsIconEnabled() {
|
||||||
output += restColor.Sprintf("%s ", icons.IconForFile(name, isSubmodule, isDirectory))
|
output += restColor.Sprintf("%s ", icons.IconForFile(name, isSubmodule, isDirectory))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +197,7 @@ func getCommitFileLine(name string, diffName string, commitFile *models.CommitFi
|
|||||||
isSubmodule := false // TODO: submodule
|
isSubmodule := false // TODO: submodule
|
||||||
isDirectory := commitFile == nil
|
isDirectory := commitFile == nil
|
||||||
|
|
||||||
if showFileIcon {
|
if icons.IsIconEnabled() {
|
||||||
output += colour.Sprintf("%s ", icons.IconForFile(name, isSubmodule, isDirectory))
|
output += colour.Sprintf("%s ", icons.IconForFile(name, isSubmodule, isDirectory))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,7 +221,3 @@ func getColorForChangeStatus(changeStatus string) style.TextStyle {
|
|||||||
return theme.DefaultTextColor
|
return theme.DefaultTextColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func SetShowFileIcon(show bool) {
|
|
||||||
showFileIcon = show
|
|
||||||
}
|
|
||||||
|
14
pkg/gui/presentation/icons/git_icons.go
Normal file
14
pkg/gui/presentation/icons/git_icons.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package icons
|
||||||
|
|
||||||
|
import "github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
|
|
||||||
|
const BRANCH_ICON = "\ufb2b" // שׂ
|
||||||
|
const COMMIT_ICON = "\ufc16" // ﰖ
|
||||||
|
const MERGE_COMMIT_ICON = "\ufb2c" // שּׁ
|
||||||
|
|
||||||
|
func IconForCommit(commit *models.Commit) string {
|
||||||
|
if len(commit.Parents) > 1 {
|
||||||
|
return MERGE_COMMIT_ICON
|
||||||
|
}
|
||||||
|
return COMMIT_ICON
|
||||||
|
}
|
11
pkg/gui/presentation/icons/icons.go
Normal file
11
pkg/gui/presentation/icons/icons.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package icons
|
||||||
|
|
||||||
|
var isIconEnabled = false
|
||||||
|
|
||||||
|
func IsIconEnabled() bool {
|
||||||
|
return isIconEnabled
|
||||||
|
}
|
||||||
|
|
||||||
|
func SetIconEnabled(showIcons bool) {
|
||||||
|
isIconEnabled = showIcons
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user