-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better commit lines in fullscreen mode
- Loading branch information
1 parent
b8717d7
commit 9fd9fd6
Showing
7 changed files
with
204 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package presentation | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/fatih/color" | ||
"github.com/jesseduffield/lazygit/pkg/commands" | ||
"github.com/jesseduffield/lazygit/pkg/theme" | ||
"github.com/jesseduffield/lazygit/pkg/utils" | ||
) | ||
|
||
func GetCommitListDisplayStrings(commits []*commands.Commit, fullDescription bool) [][]string { | ||
lines := make([][]string, len(commits)) | ||
|
||
var displayFunc func(*commands.Commit) []string | ||
if fullDescription { | ||
displayFunc = getFullDescriptionDisplayStringsForCommit | ||
} else { | ||
displayFunc = getDisplayStringsForCommit | ||
} | ||
|
||
for i := range commits { | ||
lines[i] = displayFunc(commits[i]) | ||
} | ||
|
||
return lines | ||
} | ||
|
||
func getFullDescriptionDisplayStringsForCommit(c *commands.Commit) []string { | ||
red := color.New(color.FgRed) | ||
yellow := color.New(color.FgYellow) | ||
green := color.New(color.FgGreen) | ||
blue := color.New(color.FgBlue) | ||
cyan := color.New(color.FgCyan) | ||
defaultColor := color.New(theme.DefaultTextColor) | ||
magenta := color.New(color.FgMagenta) | ||
|
||
// for some reason, setting the background to blue pads out the other commits | ||
// horizontally. For the sake of accessibility I'm considering this a feature, | ||
// not a bug | ||
copied := color.New(color.FgCyan, color.BgBlue) | ||
|
||
var shaColor *color.Color | ||
switch c.Status { | ||
case "unpushed": | ||
shaColor = red | ||
case "pushed": | ||
shaColor = yellow | ||
case "merged": | ||
shaColor = green | ||
case "rebasing": | ||
shaColor = blue | ||
case "reflog": | ||
shaColor = blue | ||
case "selected": | ||
shaColor = magenta | ||
default: | ||
shaColor = defaultColor | ||
} | ||
|
||
if c.Copied { | ||
shaColor = copied | ||
} | ||
|
||
tagString := "" | ||
truncatedDate := utils.TruncateWithEllipsis(c.Date, 15) | ||
secondColumnString := blue.Sprint(truncatedDate) | ||
if c.Action != "" { | ||
secondColumnString = cyan.Sprint(c.Action) | ||
} else if len(c.Tags) > 0 { | ||
tagColor := color.New(color.FgMagenta, color.Bold) | ||
tagString = utils.ColoredStringDirect(c.ExtraInfo, tagColor) + " " | ||
} | ||
|
||
truncatedAuthor := utils.TruncateWithEllipsis(c.Author, 17) | ||
|
||
return []string{shaColor.Sprint(c.Sha[:8]), secondColumnString, yellow.Sprint(truncatedAuthor), tagString + defaultColor.Sprint(c.Name)} | ||
} | ||
|
||
func getDisplayStringsForCommit(c *commands.Commit) []string { | ||
red := color.New(color.FgRed) | ||
yellow := color.New(color.FgYellow) | ||
green := color.New(color.FgGreen) | ||
blue := color.New(color.FgBlue) | ||
cyan := color.New(color.FgCyan) | ||
defaultColor := color.New(theme.DefaultTextColor) | ||
magenta := color.New(color.FgMagenta) | ||
|
||
// for some reason, setting the background to blue pads out the other commits | ||
// horizontally. For the sake of accessibility I'm considering this a feature, | ||
// not a bug | ||
copied := color.New(color.FgCyan, color.BgBlue) | ||
|
||
var shaColor *color.Color | ||
switch c.Status { | ||
case "unpushed": | ||
shaColor = red | ||
case "pushed": | ||
shaColor = yellow | ||
case "merged": | ||
shaColor = green | ||
case "rebasing": | ||
shaColor = blue | ||
case "reflog": | ||
shaColor = blue | ||
case "selected": | ||
shaColor = magenta | ||
default: | ||
shaColor = defaultColor | ||
} | ||
|
||
if c.Copied { | ||
shaColor = copied | ||
} | ||
|
||
actionString := "" | ||
tagString := "" | ||
if c.Action != "" { | ||
actionString = cyan.Sprint(utils.WithPadding(c.Action, 7)) + " " | ||
} else if len(c.Tags) > 0 { | ||
tagColor := color.New(color.FgMagenta, color.Bold) | ||
tagString = utils.ColoredStringDirect(strings.Join(c.Tags, " "), tagColor) + " " | ||
} | ||
|
||
return []string{shaColor.Sprint(c.Sha[:8]), actionString + tagString + defaultColor.Sprint(c.Name)} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters