mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 11:02:41 +03:00
Add config option for length of commit hash displayed in commits view
- Add config option `commitHashLength` to to pkg/config/user_config.go - Changed the hash display in pkg/gui/presentation/commits.go
This commit is contained in:
committed by
Stefan Haller
parent
aa81e191e2
commit
a4354ccdfb
@@ -80,6 +80,7 @@ gui:
|
|||||||
showIcons: false # deprecated: use nerdFontsVersion instead
|
showIcons: false # deprecated: use nerdFontsVersion instead
|
||||||
nerdFontsVersion: "" # nerd fonts version to use ("2" or "3"); empty means don't show nerd font icons
|
nerdFontsVersion: "" # nerd fonts version to use ("2" or "3"); empty means don't show nerd font icons
|
||||||
showFileIcons: true # for hiding file icons in the file views
|
showFileIcons: true # for hiding file icons in the file views
|
||||||
|
commitHashLength: 8 # length of commit hash in commits view. 0 shows '*' if NF icons aren't enabled
|
||||||
commandLogSize: 8
|
commandLogSize: 8
|
||||||
splitDiff: 'auto' # one of 'auto' | 'always'
|
splitDiff: 'auto' # one of 'auto' | 'always'
|
||||||
skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor
|
skipRewordInEditorWarning: false # for skipping the confirmation before launching the reword editor
|
||||||
|
@@ -123,6 +123,8 @@ type GuiConfig struct {
|
|||||||
NerdFontsVersion string `yaml:"nerdFontsVersion" jsonschema:"enum=2,enum=3,enum="`
|
NerdFontsVersion string `yaml:"nerdFontsVersion" jsonschema:"enum=2,enum=3,enum="`
|
||||||
// If true (default), file icons are shown in the file views. Only relevant if NerdFontsVersion is not empty.
|
// If true (default), file icons are shown in the file views. Only relevant if NerdFontsVersion is not empty.
|
||||||
ShowFileIcons bool `yaml:"showFileIcons"`
|
ShowFileIcons bool `yaml:"showFileIcons"`
|
||||||
|
// Length of commit hash in commits view. 0 shows '*' if NF icons aren't on.
|
||||||
|
CommitHashLength int `yaml:"commitHashLength" jsonschema:"minimum=0"`
|
||||||
// If true, show commit hashes alongside branch names in the branches view.
|
// If true, show commit hashes alongside branch names in the branches view.
|
||||||
ShowBranchCommitHash bool `yaml:"showBranchCommitHash"`
|
ShowBranchCommitHash bool `yaml:"showBranchCommitHash"`
|
||||||
// Height of the command log view
|
// Height of the command log view
|
||||||
@@ -675,6 +677,7 @@ func GetDefaultConfig() *UserConfig {
|
|||||||
ShowIcons: false,
|
ShowIcons: false,
|
||||||
NerdFontsVersion: "",
|
NerdFontsVersion: "",
|
||||||
ShowFileIcons: true,
|
ShowFileIcons: true,
|
||||||
|
CommitHashLength: 8,
|
||||||
ShowBranchCommitHash: false,
|
ShowBranchCommitHash: false,
|
||||||
CommandLogSize: 8,
|
CommandLogSize: 8,
|
||||||
SplitDiff: "auto",
|
SplitDiff: "auto",
|
||||||
|
@@ -312,9 +312,19 @@ func displayCommit(
|
|||||||
bisectInfo *git_commands.BisectInfo,
|
bisectInfo *git_commands.BisectInfo,
|
||||||
isYouAreHereCommit bool,
|
isYouAreHereCommit bool,
|
||||||
) []string {
|
) []string {
|
||||||
hashColor := getHashColor(commit, diffName, cherryPickedCommitHashSet, bisectStatus, bisectInfo)
|
|
||||||
bisectString := getBisectStatusText(bisectStatus, bisectInfo)
|
bisectString := getBisectStatusText(bisectStatus, bisectInfo)
|
||||||
|
|
||||||
|
hashString := ""
|
||||||
|
hashColor := getHashColor(commit, diffName, cherryPickedCommitHashSet, bisectStatus, bisectInfo)
|
||||||
|
hashLength := common.UserConfig.Gui.CommitHashLength
|
||||||
|
if hashLength >= len(commit.Hash) {
|
||||||
|
hashString = hashColor.Sprint(commit.Hash)
|
||||||
|
} else if hashLength > 0 {
|
||||||
|
hashString = hashColor.Sprint(commit.Hash[:hashLength])
|
||||||
|
} else if !icons.IsIconEnabled() { // hashLength <= 0
|
||||||
|
hashString = hashColor.Sprint("*")
|
||||||
|
}
|
||||||
|
|
||||||
actionString := ""
|
actionString := ""
|
||||||
if commit.Action != models.ActionNone {
|
if commit.Action != models.ActionNone {
|
||||||
todoString := lo.Ternary(commit.Action == models.ActionConflict, "conflict", commit.Action.String())
|
todoString := lo.Ternary(commit.Action == models.ActionConflict, "conflict", commit.Action.String())
|
||||||
@@ -373,7 +383,7 @@ func displayCommit(
|
|||||||
} else if icons.IsIconEnabled() {
|
} else if icons.IsIconEnabled() {
|
||||||
cols = append(cols, hashColor.Sprint(icons.IconForCommit(commit)))
|
cols = append(cols, hashColor.Sprint(icons.IconForCommit(commit)))
|
||||||
}
|
}
|
||||||
cols = append(cols, hashColor.Sprint(commit.ShortHash()))
|
cols = append(cols, hashString)
|
||||||
cols = append(cols, bisectString)
|
cols = append(cols, bisectString)
|
||||||
if fullDescription {
|
if fullDescription {
|
||||||
cols = append(cols, style.FgBlue.Sprint(
|
cols = append(cols, style.FgBlue.Sprint(
|
||||||
|
@@ -309,6 +309,12 @@
|
|||||||
"description": "If true (default), file icons are shown in the file views. Only relevant if NerdFontsVersion is not empty.",
|
"description": "If true (default), file icons are shown in the file views. Only relevant if NerdFontsVersion is not empty.",
|
||||||
"default": true
|
"default": true
|
||||||
},
|
},
|
||||||
|
"commitHashLength": {
|
||||||
|
"type": "integer",
|
||||||
|
"minimum": 0,
|
||||||
|
"description": "Length of commit hash in commits view. 0 shows '*' if NF icons aren't on.",
|
||||||
|
"default": 8
|
||||||
|
},
|
||||||
"showBranchCommitHash": {
|
"showBranchCommitHash": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "If true, show commit hashes alongside branch names in the branches view."
|
"description": "If true, show commit hashes alongside branch names in the branches view."
|
||||||
|
Reference in New Issue
Block a user