diff options
author | Olivia Bahr <ob.bahr@gmail.com> | 2024-04-19 14:53:03 -0600 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-04-27 11:30:49 +0200 |
commit | a4354ccdfb25cac9f4928823dae86336c7571664 (patch) | |
tree | 79bda5255ede79f4337a6d63f1dd4a223de66bea /pkg | |
parent | aa81e191e2905e6959f1d8e51c8589764ca0c520 (diff) |
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
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/config/user_config.go | 3 | ||||
-rw-r--r-- | pkg/gui/presentation/commits.go | 14 |
2 files changed, 15 insertions, 2 deletions
diff --git a/pkg/config/user_config.go b/pkg/config/user_config.go index 29b46e903..c1562fcde 100644 --- a/pkg/config/user_config.go +++ b/pkg/config/user_config.go @@ -123,6 +123,8 @@ type GuiConfig struct { 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. 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. ShowBranchCommitHash bool `yaml:"showBranchCommitHash"` // Height of the command log view @@ -675,6 +677,7 @@ func GetDefaultConfig() *UserConfig { ShowIcons: false, NerdFontsVersion: "", ShowFileIcons: true, + CommitHashLength: 8, ShowBranchCommitHash: false, CommandLogSize: 8, SplitDiff: "auto", diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index 827648dda..e3867430f 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -312,9 +312,19 @@ func displayCommit( bisectInfo *git_commands.BisectInfo, isYouAreHereCommit bool, ) []string { - hashColor := getHashColor(commit, diffName, cherryPickedCommitHashSet, 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 := "" if commit.Action != models.ActionNone { todoString := lo.Ternary(commit.Action == models.ActionConflict, "conflict", commit.Action.String()) @@ -373,7 +383,7 @@ func displayCommit( } else if icons.IsIconEnabled() { cols = append(cols, hashColor.Sprint(icons.IconForCommit(commit))) } - cols = append(cols, hashColor.Sprint(commit.ShortHash())) + cols = append(cols, hashString) cols = append(cols, bisectString) if fullDescription { cols = append(cols, style.FgBlue.Sprint( |