1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

renaming variable to CommitHash

This commit is contained in:
pikomonde
2024-03-20 03:15:20 +07:00
committed by Stefan Haller
parent 7f6eea2a55
commit 84333eebc3
25 changed files with 252 additions and 252 deletions

View File

@ -67,8 +67,8 @@ func (self *BisectInfo) GetStartSha() string {
return self.start
}
func (self *BisectInfo) Status(commitSha string) (BisectStatus, bool) {
status, ok := self.statusMap[commitSha]
func (self *BisectInfo) Status(commitHash string) (BisectStatus, bool) {
status, ok := self.statusMap[commitHash]
return status, ok
}

View File

@ -155,9 +155,9 @@ func (self *CommitCommands) signoffFlag() string {
}
}
func (self *CommitCommands) GetCommitMessage(commitSha string) (string, error) {
func (self *CommitCommands) GetCommitMessage(commitHash string) (string, error) {
cmdArgs := NewGitCmd("log").
Arg("--format=%B", "--max-count=1", commitSha).
Arg("--format=%B", "--max-count=1", commitHash).
Config("log.showsignature=false").
ToArgv()
@ -165,9 +165,9 @@ func (self *CommitCommands) GetCommitMessage(commitSha string) (string, error) {
return strings.ReplaceAll(strings.TrimSpace(message), "\r\n", "\n"), err
}
func (self *CommitCommands) GetCommitSubject(commitSha string) (string, error) {
func (self *CommitCommands) GetCommitSubject(commitHash string) (string, error) {
cmdArgs := NewGitCmd("log").
Arg("--format=%s", "--max-count=1", commitSha).
Arg("--format=%s", "--max-count=1", commitHash).
Config("log.showsignature=false").
ToArgv()
@ -175,8 +175,8 @@ func (self *CommitCommands) GetCommitSubject(commitSha string) (string, error) {
return strings.TrimSpace(subject), err
}
func (self *CommitCommands) GetCommitDiff(commitSha string) (string, error) {
cmdArgs := NewGitCmd("show").Arg("--no-color", commitSha).ToArgv()
func (self *CommitCommands) GetCommitDiff(commitHash string) (string, error) {
cmdArgs := NewGitCmd("show").Arg("--no-color", commitHash).ToArgv()
diff, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
return diff, err
@ -187,9 +187,9 @@ type Author struct {
Email string
}
func (self *CommitCommands) GetCommitAuthor(commitSha string) (Author, error) {
func (self *CommitCommands) GetCommitAuthor(commitHash string) (Author, error) {
cmdArgs := NewGitCmd("show").
Arg("--no-patch", "--pretty=format:'%an%x00%ae'", commitSha).
Arg("--no-patch", "--pretty=format:'%an%x00%ae'", commitHash).
ToArgv()
output, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()

View File

@ -260,7 +260,7 @@ func (self *CommitLoader) getHydratedRebasingCommits(rebaseMode enums.RebaseMode
return nil, nil
}
commitShas := lo.FilterMap(commits, func(commit *models.Commit, _ int) (string, bool) {
commitHashes := lo.FilterMap(commits, func(commit *models.Commit, _ int) (string, bool) {
return commit.Sha, commit.Sha != ""
})
@ -270,7 +270,7 @@ func (self *CommitLoader) getHydratedRebasingCommits(rebaseMode enums.RebaseMode
NewGitCmd("show").
Config("log.showSignature=false").
Arg("--no-patch", "--oneline", "--abbrev=20", prettyFormat).
Arg(commitShas...).
Arg(commitHashes...).
ToArgv(),
).DontLog()
@ -337,9 +337,9 @@ func (self *CommitLoader) getRebasingCommits(rebaseMode enums.RebaseMode) []*mod
// See if the current commit couldn't be applied because it conflicted; if
// so, add a fake entry for it
if conflictedCommitSha := self.getConflictedCommit(todos); conflictedCommitSha != "" {
if conflictedCommitHash := self.getConflictedCommit(todos); conflictedCommitHash != "" {
commits = append(commits, &models.Commit{
Sha: conflictedCommitSha,
Sha: conflictedCommitHash,
Name: "",
Status: models.StatusRebasing,
Action: models.ActionConflict,

View File

@ -313,8 +313,8 @@ func (self *WorkingTreeCommands) ShowFileDiffCmdObj(from string, to string, reve
}
// CheckoutFile checks out the file for the given commit
func (self *WorkingTreeCommands) CheckoutFile(commitSha, fileName string) error {
cmdArgs := NewGitCmd("checkout").Arg(commitSha, "--", fileName).
func (self *WorkingTreeCommands) CheckoutFile(commitHash, fileName string) error {
cmdArgs := NewGitCmd("checkout").Arg(commitHash, "--", fileName).
ToArgv()
return self.cmd.New(cmdArgs).Run()

View File

@ -398,7 +398,7 @@ func TestWorkingTreeShowFileDiff(t *testing.T) {
func TestWorkingTreeCheckoutFile(t *testing.T) {
type scenario struct {
testName string
commitSha string
commitHash string
fileName string
runner *oscommands.FakeCmdObjRunner
test func(error)
@ -407,7 +407,7 @@ func TestWorkingTreeCheckoutFile(t *testing.T) {
scenarios := []scenario{
{
testName: "typical case",
commitSha: "11af912",
commitHash: "11af912",
fileName: "test999.txt",
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"checkout", "11af912", "--", "test999.txt"}, "", nil),
@ -417,7 +417,7 @@ func TestWorkingTreeCheckoutFile(t *testing.T) {
},
{
testName: "returns error if there is one",
commitSha: "11af912",
commitHash: "11af912",
fileName: "test999.txt",
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"checkout", "11af912", "--", "test999.txt"}, "", errors.New("error")),
@ -432,7 +432,7 @@ func TestWorkingTreeCheckoutFile(t *testing.T) {
t.Run(s.testName, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
s.test(instance.CheckoutFile(s.commitSha, s.fileName))
s.test(instance.CheckoutFile(s.commitHash, s.fileName))
s.runner.CheckForMissingCalls()
})
}

View File

@ -14,7 +14,7 @@ var githubServiceDef = ServiceDefinition{
provider: "github",
pullRequestURLIntoDefaultBranch: "/compare/{{.From}}?expand=1",
pullRequestURLIntoTargetBranch: "/compare/{{.To}}...{{.From}}?expand=1",
commitURL: "/commit/{{.CommitSha}}",
commitURL: "/commit/{{.CommitHash}}",
regexStrings: defaultUrlRegexStrings,
repoURLTemplate: defaultRepoURLTemplate,
}
@ -23,7 +23,7 @@ var bitbucketServiceDef = ServiceDefinition{
provider: "bitbucket",
pullRequestURLIntoDefaultBranch: "/pull-requests/new?source={{.From}}&t=1",
pullRequestURLIntoTargetBranch: "/pull-requests/new?source={{.From}}&dest={{.To}}&t=1",
commitURL: "/commits/{{.CommitSha}}",
commitURL: "/commits/{{.CommitHash}}",
regexStrings: []string{
`^(?:https?|ssh)://.*/(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
`^.*@.*:(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
@ -35,7 +35,7 @@ var gitLabServiceDef = ServiceDefinition{
provider: "gitlab",
pullRequestURLIntoDefaultBranch: "/-/merge_requests/new?merge_request[source_branch]={{.From}}",
pullRequestURLIntoTargetBranch: "/-/merge_requests/new?merge_request[source_branch]={{.From}}&merge_request[target_branch]={{.To}}",
commitURL: "/-/commit/{{.CommitSha}}",
commitURL: "/-/commit/{{.CommitHash}}",
regexStrings: defaultUrlRegexStrings,
repoURLTemplate: defaultRepoURLTemplate,
}
@ -44,7 +44,7 @@ var azdoServiceDef = ServiceDefinition{
provider: "azuredevops",
pullRequestURLIntoDefaultBranch: "/pullrequestcreate?sourceRef={{.From}}",
pullRequestURLIntoTargetBranch: "/pullrequestcreate?sourceRef={{.From}}&targetRef={{.To}}",
commitURL: "/commit/{{.CommitSha}}",
commitURL: "/commit/{{.CommitHash}}",
regexStrings: []string{
`^git@ssh.dev.azure.com.*/(?P<org>.*)/(?P<project>.*)/(?P<repo>.*?)(?:\.git)?$`,
`^https://.*@dev.azure.com/(?P<org>.*?)/(?P<project>.*?)/_git/(?P<repo>.*?)(?:\.git)?$`,
@ -56,7 +56,7 @@ var bitbucketServerServiceDef = ServiceDefinition{
provider: "bitbucketServer",
pullRequestURLIntoDefaultBranch: "/pull-requests?create&sourceBranch={{.From}}",
pullRequestURLIntoTargetBranch: "/pull-requests?create&targetBranch={{.To}}&sourceBranch={{.From}}",
commitURL: "/commits/{{.CommitSha}}",
commitURL: "/commits/{{.CommitHash}}",
regexStrings: []string{
`^ssh://git@.*/(?P<project>.*)/(?P<repo>.*?)(?:\.git)?$`,
`^https://.*/scm/(?P<project>.*)/(?P<repo>.*?)(?:\.git)?$`,
@ -68,7 +68,7 @@ var giteaServiceDef = ServiceDefinition{
provider: "gitea",
pullRequestURLIntoDefaultBranch: "/compare/{{.From}}",
pullRequestURLIntoTargetBranch: "/compare/{{.To}}...{{.From}}",
commitURL: "/commit/{{.CommitSha}}",
commitURL: "/commit/{{.CommitHash}}",
regexStrings: defaultUrlRegexStrings,
repoURLTemplate: defaultRepoURLTemplate,
}

View File

@ -51,13 +51,13 @@ func (self *HostingServiceMgr) GetPullRequestURL(from string, to string) (string
}
}
func (self *HostingServiceMgr) GetCommitURL(commitSha string) (string, error) {
func (self *HostingServiceMgr) GetCommitURL(commitHash string) (string, error) {
gitService, err := self.getService()
if err != nil {
return "", err
}
pullRequestURL := gitService.getCommitURL(commitSha)
pullRequestURL := gitService.getCommitURL(commitHash)
return pullRequestURL, nil
}
@ -174,8 +174,8 @@ func (self *Service) getPullRequestURLIntoTargetBranch(from string, to string) s
return self.resolveUrl(self.pullRequestURLIntoTargetBranch, map[string]string{"From": from, "To": to})
}
func (self *Service) getCommitURL(commitSha string) string {
return self.resolveUrl(self.commitURL, map[string]string{"CommitSha": commitSha})
func (self *Service) getCommitURL(commitHash string) string {
return self.resolveUrl(self.commitURL, map[string]string{"CommitHash": commitHash})
}
func (self *Service) resolveUrl(templateString string, args map[string]string) string {

View File

@ -29,12 +29,12 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
)
getDisplayStrings := func(startIdx int, endIdx int) [][]string {
selectedCommitSha := ""
selectedCommitHash := ""
if c.CurrentContext().GetKey() == LOCAL_COMMITS_CONTEXT_KEY {
selectedCommit := viewModel.GetSelected()
if selectedCommit != nil {
selectedCommitSha = selectedCommit.Sha
selectedCommitHash = selectedCommit.Sha
}
}
@ -55,7 +55,7 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
c.UserConfig.Gui.ShortTimeFormat,
time.Now(),
c.UserConfig.Git.ParseEmoji,
selectedCommitSha,
selectedCommitHash,
startIdx,
endIdx,
shouldShowGraph(c),

View File

@ -44,11 +44,11 @@ func NewSubCommitsContext(
return [][]string{}
}
selectedCommitSha := ""
selectedCommitHash := ""
if c.CurrentContext().GetKey() == SUB_COMMITS_CONTEXT_KEY {
selectedCommit := viewModel.GetSelected()
if selectedCommit != nil {
selectedCommitSha = selectedCommit.Sha
selectedCommitHash = selectedCommit.Sha
}
}
branches := []*models.Branch{}
@ -70,7 +70,7 @@ func NewSubCommitsContext(
c.UserConfig.Gui.ShortTimeFormat,
time.Now(),
c.UserConfig.Git.ParseEmoji,
selectedCommitSha,
selectedCommitHash,
startIdx,
endIdx,
// Don't show the graph in the left/right view; we'd like to, but

View File

@ -125,9 +125,9 @@ func (self *BasicCommitsController) copyCommitAttribute(commit *models.Commit) e
Title: self.c.Tr.Actions.CopyCommitAttributeToClipboard,
Items: []*types.MenuItem{
{
Label: self.c.Tr.CommitSha,
Label: self.c.Tr.CommitHash,
OnPress: func() error {
return self.copyCommitSHAToClipboard(commit)
return self.copyCommitHashToClipboard(commit)
},
},
{
@ -169,8 +169,8 @@ func (self *BasicCommitsController) copyCommitAttribute(commit *models.Commit) e
})
}
func (self *BasicCommitsController) copyCommitSHAToClipboard(commit *models.Commit) error {
self.c.LogAction(self.c.Tr.Actions.CopyCommitSHAToClipboard)
func (self *BasicCommitsController) copyCommitHashToClipboard(commit *models.Commit) error {
self.c.LogAction(self.c.Tr.Actions.CopyCommitHashToClipboard)
if err := self.c.OS().CopyToClipboard(commit.Sha); err != nil {
return self.c.Error(err)
}

View File

@ -8,7 +8,7 @@ import (
type IHostHelper interface {
GetPullRequestURL(from string, to string) (string, error)
GetCommitURL(commitSha string) (string, error)
GetCommitURL(commitHash string) (string, error)
}
type HostHelper struct {
@ -31,12 +31,12 @@ func (self *HostHelper) GetPullRequestURL(from string, to string) (string, error
return mgr.GetPullRequestURL(from, to)
}
func (self *HostHelper) GetCommitURL(commitSha string) (string, error) {
func (self *HostHelper) GetCommitURL(commitHash string) (string, error) {
mgr, err := self.getHostingServiceMgr()
if err != nil {
return "", err
}
return mgr.GetCommitURL(commitSha)
return mgr.GetCommitURL(commitHash)
}
// getting this on every request rather than storing it in state in case our remoteURL changes

View File

@ -181,34 +181,34 @@ func (self *UndoController) reflogRedo() error {
func (self *UndoController) parseReflogForActions(onUserAction func(counter int, action reflogAction) (bool, error)) error {
counter := 0
reflogCommits := self.c.Model().FilteredReflogCommits
rebaseFinishCommitSha := ""
rebaseFinishCommitHash := ""
var action *reflogAction
for reflogCommitIdx, reflogCommit := range reflogCommits {
action = nil
prevCommitSha := ""
prevCommitHash := ""
if len(reflogCommits)-1 >= reflogCommitIdx+1 {
prevCommitSha = reflogCommits[reflogCommitIdx+1].Sha
prevCommitHash = reflogCommits[reflogCommitIdx+1].Sha
}
if rebaseFinishCommitSha == "" {
if rebaseFinishCommitHash == "" {
if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^\[lazygit undo\]`); ok {
counter++
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^\[lazygit redo\]`); ok {
counter--
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^rebase (-i )?\(abort\)|^rebase (-i )?\(finish\)`); ok {
rebaseFinishCommitSha = reflogCommit.Sha
rebaseFinishCommitHash = reflogCommit.Sha
} else if ok, match := utils.FindStringSubmatch(reflogCommit.Name, `^checkout: moving from ([\S]+) to ([\S]+)`); ok {
action = &reflogAction{kind: CHECKOUT, from: match[1], to: match[2]}
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^commit|^reset: moving to|^pull`); ok {
action = &reflogAction{kind: COMMIT, from: prevCommitSha, to: reflogCommit.Sha}
action = &reflogAction{kind: COMMIT, from: prevCommitHash, to: reflogCommit.Sha}
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^rebase (-i )?\(start\)`); ok {
// if we're here then we must be currently inside an interactive rebase
action = &reflogAction{kind: CURRENT_REBASE, from: prevCommitSha}
action = &reflogAction{kind: CURRENT_REBASE, from: prevCommitHash}
}
} else if ok, _ := utils.FindStringSubmatch(reflogCommit.Name, `^rebase (-i )?\(start\)`); ok {
action = &reflogAction{kind: REBASE, from: prevCommitSha, to: rebaseFinishCommitSha}
rebaseFinishCommitSha = ""
action = &reflogAction{kind: REBASE, from: prevCommitHash, to: rebaseFinishCommitHash}
rebaseFinishCommitHash = ""
}
if action != nil {
@ -232,9 +232,9 @@ type hardResetOptions struct {
}
// only to be used in the undo flow for now (does an autostash)
func (self *UndoController) hardResetWithAutoStash(commitSha string, options hardResetOptions) error {
func (self *UndoController) hardResetWithAutoStash(commitHash string, options hardResetOptions) error {
reset := func() error {
if err := self.c.Helpers().Refs.ResetToRef(commitSha, "hard", options.EnvVars); err != nil {
if err := self.c.Helpers().Refs.ResetToRef(commitHash, "hard", options.EnvVars); err != nil {
return self.c.Error(err)
}
return nil
@ -249,7 +249,7 @@ func (self *UndoController) hardResetWithAutoStash(commitSha string, options har
Prompt: self.c.Tr.AutoStashPrompt,
HandleConfirm: func() error {
return self.c.WithWaitingStatus(options.WaitingStatus, func(gocui.Task) error {
if err := self.c.Git().Stash.Push(self.c.Tr.StashPrefix + commitSha); err != nil {
if err := self.c.Git().Stash.Push(self.c.Tr.StashPrefix + commitHash); err != nil {
return self.c.Error(err)
}
if err := reset(); err != nil {

View File

@ -148,7 +148,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
Handler: self.handleCopySelectedSideContextItemCommitHashToClipboard,
GetDisabledReason: self.getCopySelectedSideContextItemToClipboardDisabledReason,
Description: self.c.Tr.CopyCommitShaToClipboard,
Description: self.c.Tr.CopyCommitHashToClipboard,
},
{
ViewName: "commits",
@ -161,14 +161,14 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
Handler: self.handleCopySelectedSideContextItemToClipboard,
GetDisabledReason: self.getCopySelectedSideContextItemToClipboardDisabledReason,
Description: self.c.Tr.CopyCommitShaToClipboard,
Description: self.c.Tr.CopyCommitHashToClipboard,
},
{
ViewName: "subCommits",
Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
Handler: self.handleCopySelectedSideContextItemCommitHashToClipboard,
GetDisabledReason: self.getCopySelectedSideContextItemToClipboardDisabledReason,
Description: self.c.Tr.CopyCommitShaToClipboard,
Description: self.c.Tr.CopyCommitHashToClipboard,
},
{
ViewName: "information",

View File

@ -22,7 +22,7 @@ import (
)
type pipeSetCacheKey struct {
commitSha string
commitHash string
commitCount int
}
@ -43,14 +43,14 @@ func GetCommitListDisplayStrings(
currentBranchName string,
hasRebaseUpdateRefsConfig bool,
fullDescription bool,
cherryPickedCommitShaSet *set.Set[string],
cherryPickedCommitHashSet *set.Set[string],
diffName string,
markedBaseCommit string,
timeFormat string,
shortTimeFormat string,
now time.Time,
parseEmoji bool,
selectedCommitSha string,
selectedCommitHash string,
startIdx int,
endIdx int,
showGraph bool,
@ -89,7 +89,7 @@ func GetCommitListDisplayStrings(
graphLines := graph.RenderAux(
graphPipeSets,
graphCommits,
selectedCommitSha,
selectedCommitHash,
)
getGraphLine = func(idx int) string {
if idx >= graphOffset {
@ -146,7 +146,7 @@ func GetCommitListDisplayStrings(
commit,
branchHeadsToVisualize,
hasRebaseUpdateRefsConfig,
cherryPickedCommitShaSet,
cherryPickedCommitHashSet,
isMarkedBaseCommit,
willBeRebased,
diffName,
@ -203,7 +203,7 @@ func loadPipesets(commits []*models.Commit) [][]*graph.Pipe {
// given that our cache key is a commit hash and a commit count, it's very important that we don't actually try to render pipes
// when dealing with things like filtered commits.
cacheKey := pipeSetCacheKey{
commitSha: commits[0].Sha,
commitHash: commits[0].Sha,
commitCount: len(commits),
}
@ -236,16 +236,16 @@ const (
BisectStatusCurrent
)
func getBisectStatus(index int, commitSha string, bisectInfo *git_commands.BisectInfo, bisectBounds *bisectBounds) BisectStatus {
func getBisectStatus(index int, commitHash string, bisectInfo *git_commands.BisectInfo, bisectBounds *bisectBounds) BisectStatus {
if !bisectInfo.Started() {
return BisectStatusNone
}
if bisectInfo.GetCurrentSha() == commitSha {
if bisectInfo.GetCurrentSha() == commitHash {
return BisectStatusCurrent
}
status, ok := bisectInfo.Status(commitSha)
status, ok := bisectInfo.Status(commitHash)
if ok {
switch status {
case git_commands.BisectStatusNew:
@ -298,7 +298,7 @@ func displayCommit(
commit *models.Commit,
branchHeadsToVisualize *set.Set[string],
hasRebaseUpdateRefsConfig bool,
cherryPickedCommitShaSet *set.Set[string],
cherryPickedCommitHashSet *set.Set[string],
isMarkedBaseCommit bool,
willBeRebased bool,
diffName string,
@ -312,7 +312,7 @@ func displayCommit(
bisectInfo *git_commands.BisectInfo,
isYouAreHereCommit bool,
) []string {
shaColor := getShaColor(commit, diffName, cherryPickedCommitShaSet, bisectStatus, bisectInfo)
shaColor := getShaColor(commit, diffName, cherryPickedCommitHashSet, bisectStatus, bisectInfo)
bisectString := getBisectStatusText(bisectStatus, bisectInfo)
actionString := ""
@ -413,7 +413,7 @@ func getBisectStatusColor(status BisectStatus) style.TextStyle {
func getShaColor(
commit *models.Commit,
diffName string,
cherryPickedCommitShaSet *set.Set[string],
cherryPickedCommitHashSet *set.Set[string],
bisectStatus BisectStatus,
bisectInfo *git_commands.BisectInfo,
) style.TextStyle {
@ -439,7 +439,7 @@ func getShaColor(
if diffed {
shaColor = theme.DiffTerminalColor
} else if cherryPickedCommitShaSet.Includes(commit.Sha) {
} else if cherryPickedCommitHashSet.Includes(commit.Sha) {
shaColor = theme.CherryPickedCommitTextStyle
} else if commit.Divergence == models.DivergenceRight && commit.Status != models.StatusMerged {
shaColor = style.FgBlue

View File

@ -28,14 +28,14 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
currentBranchName string
hasUpdateRefConfig bool
fullDescription bool
cherryPickedCommitShaSet *set.Set[string]
cherryPickedCommitHashSet *set.Set[string]
markedBaseCommit string
diffName string
timeFormat string
shortTimeFormat string
now time.Time
parseEmoji bool
selectedCommitSha string
selectedCommitHash string
startIdx int
endIdx int
showGraph bool
@ -51,7 +51,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 1,
showGraph: false,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: "",
},
@ -65,7 +65,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 2,
showGraph: false,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
sha1 commit1
@ -82,7 +82,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 2,
showGraph: false,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
sha1 tag1 tag2 commit1
@ -109,7 +109,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 4,
showGraph: false,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
sha1 commit1
@ -134,7 +134,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 2,
showGraph: false,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
sha1 * commit1
@ -157,7 +157,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 2,
showGraph: false,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
sha1 commit1
@ -178,7 +178,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 3,
showGraph: false,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
sha1 commit1
@ -199,7 +199,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 5,
showGraph: true,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
sha1 ⏣─╮ commit1
@ -222,7 +222,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 5,
showGraph: true,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
showYouAreHereLabel: true,
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
@ -246,7 +246,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 5,
showGraph: true,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
showYouAreHereLabel: true,
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
@ -269,7 +269,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 5,
showGraph: true,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
showYouAreHereLabel: true,
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
@ -290,7 +290,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 2,
showGraph: true,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
showYouAreHereLabel: true,
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
@ -311,7 +311,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 5,
showGraph: true,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
showYouAreHereLabel: true,
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
@ -331,7 +331,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 2,
showGraph: true,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
showYouAreHereLabel: true,
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
@ -350,7 +350,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 3,
showGraph: true,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
showYouAreHereLabel: false,
now: time.Date(2020, 1, 1, 0, 0, 0, 0, time.UTC),
expected: formatExpected(`
@ -372,7 +372,7 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
endIdx: 2,
showGraph: false,
bisectInfo: git_commands.NewNullBisectInfo(),
cherryPickedCommitShaSet: set.New[string](),
cherryPickedCommitHashSet: set.New[string](),
now: time.Date(2020, 1, 1, 5, 3, 4, 0, time.UTC),
expected: formatExpected(`
sha1 2:03AM Jesse Duffield commit1
@ -406,14 +406,14 @@ func TestGetCommitListDisplayStrings(t *testing.T) {
s.currentBranchName,
s.hasUpdateRefConfig,
s.fullDescription,
s.cherryPickedCommitShaSet,
s.cherryPickedCommitHashSet,
s.diffName,
s.markedBaseCommit,
s.timeFormat,
s.shortTimeFormat,
s.now,
s.parseEmoji,
s.selectedCommitSha,
s.selectedCommitHash,
s.startIdx,
s.endIdx,
s.showGraph,

View File

@ -32,7 +32,7 @@ type Pipe struct {
var highlightStyle = style.FgLightWhite.SetBold()
func ContainsCommitSha(pipes []*Pipe, sha string) bool {
func ContainsCommitHash(pipes []*Pipe, sha string) bool {
for _, pipe := range pipes {
if equalHashes(pipe.fromSha, sha) {
return true
@ -49,13 +49,13 @@ func (self Pipe) right() int {
return max(self.fromPos, self.toPos)
}
func RenderCommitGraph(commits []*models.Commit, selectedCommitSha string, getStyle func(c *models.Commit) style.TextStyle) []string {
func RenderCommitGraph(commits []*models.Commit, selectedCommitHash string, getStyle func(c *models.Commit) style.TextStyle) []string {
pipeSets := GetPipeSets(commits, getStyle)
if len(pipeSets) == 0 {
return nil
}
lines := RenderAux(pipeSets, commits, selectedCommitSha)
lines := RenderAux(pipeSets, commits, selectedCommitHash)
return lines
}
@ -73,7 +73,7 @@ func GetPipeSets(commits []*models.Commit, getStyle func(c *models.Commit) style
})
}
func RenderAux(pipeSets [][]*Pipe, commits []*models.Commit, selectedCommitSha string) []string {
func RenderAux(pipeSets [][]*Pipe, commits []*models.Commit, selectedCommitHash string) []string {
maxProcs := runtime.GOMAXPROCS(0)
// splitting up the rendering of the graph into multiple goroutines allows us to render the graph in parallel
@ -98,7 +98,7 @@ func RenderAux(pipeSets [][]*Pipe, commits []*models.Commit, selectedCommitSha s
if k > 0 {
prevCommit = commits[k-1]
}
line := renderPipeSet(pipeSet, selectedCommitSha, prevCommit)
line := renderPipeSet(pipeSet, selectedCommitHash, prevCommit)
innerLines = append(innerLines, line)
}
chunks[i] = innerLines
@ -282,7 +282,7 @@ func getNextPipes(prevPipes []*Pipe, commit *models.Commit, getStyle func(c *mod
func renderPipeSet(
pipes []*Pipe,
selectedCommitSha string,
selectedCommitHash string,
prevCommit *models.Commit,
) string {
maxPos := 0
@ -329,10 +329,10 @@ func renderPipeSet(
// we don't want to highlight two commits if they're contiguous. We only want
// to highlight multiple things if there's an actual visible pipe involved.
highlight := true
if prevCommit != nil && equalHashes(prevCommit.Sha, selectedCommitSha) {
if prevCommit != nil && equalHashes(prevCommit.Sha, selectedCommitHash) {
highlight = false
for _, pipe := range pipes {
if equalHashes(pipe.fromSha, selectedCommitSha) && (pipe.kind != TERMINATES || pipe.fromPos != pipe.toPos) {
if equalHashes(pipe.fromSha, selectedCommitHash) && (pipe.kind != TERMINATES || pipe.fromPos != pipe.toPos) {
highlight = true
}
}
@ -341,7 +341,7 @@ func renderPipeSet(
// so we have our commit pos again, now it's time to build the cells.
// we'll handle the one that's sourced from our selected commit last so that it can override the other cells.
selectedPipes, nonSelectedPipes := utils.Partition(pipes, func(pipe *Pipe) bool {
return highlight && equalHashes(pipe.fromSha, selectedCommitSha)
return highlight && equalHashes(pipe.fromSha, selectedCommitHash)
})
for _, pipe := range nonSelectedPipes {
@ -385,7 +385,7 @@ func renderPipeSet(
}
func equalHashes(a, b string) bool {
// if our selectedCommitSha is an empty string we treat that as meaning there is no selected commit hash
// if our selectedCommitHash is an empty string we treat that as meaning there is no selected commit hash
if a == "" || b == "" {
return false
}

View File

@ -12,7 +12,7 @@ import (
"github.com/samber/lo"
)
func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription bool, cherryPickedCommitShaSet *set.Set[string], diffName string, now time.Time, timeFormat string, shortTimeFormat string, parseEmoji bool) [][]string {
func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription bool, cherryPickedCommitHashSet *set.Set[string], diffName string, now time.Time, timeFormat string, shortTimeFormat string, parseEmoji bool) [][]string {
var displayFunc func(*models.Commit, reflogCommitDisplayAttributes) []string
if fullDescription {
displayFunc = getFullDescriptionDisplayStringsForReflogCommit
@ -22,7 +22,7 @@ func GetReflogCommitListDisplayStrings(commits []*models.Commit, fullDescription
return lo.Map(commits, func(commit *models.Commit, _ int) []string {
diffed := commit.Sha == diffName
cherryPicked := cherryPickedCommitShaSet.Includes(commit.Sha)
cherryPicked := cherryPickedCommitHashSet.Includes(commit.Sha)
return displayFunc(commit,
reflogCommitDisplayAttributes{
cherryPicked: cherryPicked,

View File

@ -355,7 +355,7 @@ func chineseTranslationSet() TranslationSet {
// 实际视图 (actual view) 是附加视图 (extras view),未来,我打算为附加视图提供更多选项卡,但现在,上面的文本只需要提及“命令日志”这个部分
OpenCommandLogMenu: "打开命令日志菜单",
ShowingGitDiff: "显示输出:",
CopyCommitShaToClipboard: "将提交的 SHA 复制到剪贴板",
CopyCommitHashToClipboard: "将提交的 SHA 复制到剪贴板",
CopyCommitMessageToClipboard: "将提交消息复制到剪贴板",
CopyBranchNameToClipboard: "将分支名称复制到剪贴板",
CopyPathToClipboard: "将文件名复制到剪贴板",

View File

@ -308,7 +308,7 @@ func dutchTranslationSet() TranslationSet {
SwapDiff: "Keer diff richting om",
ViewDiffingOptions: "Open diff menu",
ShowingGitDiff: "Laat output zien voor:",
CopyCommitShaToClipboard: "Kopieer commit hash naar klembord",
CopyCommitHashToClipboard: "Kopieer commit hash naar klembord",
CopyCommitMessageToClipboard: "Kopieer commit bericht naar klembord",
CopyBranchNameToClipboard: "Kopieer branch name naar klembord",
CopyPathToClipboard: "Kopieer de bestandsnaam naar het klembord",

View File

@ -571,8 +571,8 @@ type TranslationSet struct {
OpenCommandLogMenuTooltip string
ShowingGitDiff string
CommitDiff string
CopyCommitShaToClipboard string
CommitSha string
CopyCommitHashToClipboard string
CommitHash string
CommitURL string
CopyCommitMessageToClipboard string
CommitMessage string
@ -855,7 +855,7 @@ type Actions struct {
CopyCommitMessageToClipboard string
CopyCommitSubjectToClipboard string
CopyCommitDiffToClipboard string
CopyCommitSHAToClipboard string
CopyCommitHashToClipboard string
CopyCommitURLToClipboard string
CopyCommitAuthorToClipboard string
CopyCommitAttributeToClipboard string
@ -1534,8 +1534,8 @@ func EnglishTranslationSet() TranslationSet {
OpenCommandLogMenuTooltip: "View options for the command log e.g. show/hide the command log and focus the command log.",
ShowingGitDiff: "Showing output for:",
CommitDiff: "Commit diff",
CopyCommitShaToClipboard: "Copy commit hash to clipboard",
CommitSha: "commit hash",
CopyCommitHashToClipboard: "Copy commit hash to clipboard",
CommitHash: "Commit hash",
CommitURL: "Commit URL",
CopyCommitMessageToClipboard: "Copy commit message to clipboard",
CommitMessage: "Commit message",
@ -1772,7 +1772,7 @@ func EnglishTranslationSet() TranslationSet {
CopyCommitMessageToClipboard: "Copy commit message to clipboard",
CopyCommitSubjectToClipboard: "Copy commit subject to clipboard",
CopyCommitDiffToClipboard: "Copy commit diff to clipboard",
CopyCommitSHAToClipboard: "Copy full commit hash to clipboard",
CopyCommitHashToClipboard: "Copy full commit hash to clipboard",
CopyCommitURLToClipboard: "Copy commit URL to clipboard",
CopyCommitAuthorToClipboard: "Copy commit author to clipboard",
CopyCommitAttributeToClipboard: "Copy to clipboard",

View File

@ -367,8 +367,8 @@ func japaneseTranslationSet() TranslationSet {
OpenCommandLogMenu: "コマンドログメニューを開く",
// LcShowingGitDiff: "Showing output for:",
CommitDiff: "コミットの差分",
CopyCommitShaToClipboard: "コミットのSHAをクリップボードにコピー",
CommitSha: "コミットのSHA",
CopyCommitHashToClipboard: "コミットのSHAをクリップボードにコピー",
CommitHash: "コミットのSHA",
CommitURL: "コミットのURL",
CopyCommitMessageToClipboard: "コミットメッセージをクリップボードにコピー",
CommitMessage: "コミットメッセージ",
@ -496,7 +496,7 @@ func japaneseTranslationSet() TranslationSet {
CreateAnnotatedTag: "注釈付きタグを作成",
CopyCommitMessageToClipboard: "コミットメッセージをクリップボードにコピー",
CopyCommitDiffToClipboard: "コミットの差分をクリップボードにコピー",
CopyCommitSHAToClipboard: "コミットSHAをクリップボードにコピー",
CopyCommitHashToClipboard: "コミットSHAをクリップボードにコピー",
CopyCommitURLToClipboard: "コミットのURLをクリップボードにコピー",
CopyCommitAuthorToClipboard: "コミットの作成者名をクリップボードにコピー",
CopyCommitAttributeToClipboard: "クリップボードにコピー",

View File

@ -361,8 +361,8 @@ func koreanTranslationSet() TranslationSet {
OpenCommandLogMenu: "명령어 로그 메뉴 열기",
ShowingGitDiff: "Showing output for:",
CommitDiff: "커밋의 iff",
CopyCommitShaToClipboard: "커밋 SHA를 클립보드에 복사",
CommitSha: "커밋 SHA",
CopyCommitHashToClipboard: "커밋 SHA를 클립보드에 복사",
CommitHash: "커밋 SHA",
CommitURL: "커밋 URL",
CopyCommitMessageToClipboard: "커밋 메시지를 클립보드에 복사",
CommitMessage: "커밋 메시지",
@ -486,7 +486,7 @@ func koreanTranslationSet() TranslationSet {
CreateAnnotatedTag: "Create annotated tag",
CopyCommitMessageToClipboard: "커밋 메시지를 클립보드에 복사",
CopyCommitDiffToClipboard: "커밋 diff를 클립보드에 복사",
CopyCommitSHAToClipboard: "커밋 SHA를 클립보드에 복사",
CopyCommitHashToClipboard: "커밋 SHA를 클립보드에 복사",
CopyCommitURLToClipboard: "커밋 URL를 클립보드에 복사",
CopyCommitAuthorToClipboard: "커밋 작성자를 클립보드에 복사",
CopyCommitAttributeToClipboard: "클립보드에 복사",

View File

@ -548,8 +548,8 @@ func polishTranslationSet() TranslationSet {
OpenCommandLogMenuTooltip: "Pokaż opcje dla dziennika poleceń, np. pokazywanie/ukrywanie dziennika poleceń i skupienie na dzienniku poleceń.",
ShowingGitDiff: "Pokazuje wynik dla:",
CommitDiff: "Różnice commita",
CopyCommitShaToClipboard: "Kopiuj SHA commita do schowka",
CommitSha: "SHA commita",
CopyCommitHashToClipboard: "Kopiuj SHA commita do schowka",
CommitHash: "SHA commita",
CommitURL: "URL commita",
CopyCommitMessageToClipboard: "Kopiuj wiadomość commita do schowka",
CommitMessage: "Wiadomość commita",
@ -784,7 +784,7 @@ func polishTranslationSet() TranslationSet {
CopyCommitMessageToClipboard: "Kopiuj wiadomość commita do schowka",
CopyCommitSubjectToClipboard: "Kopiuj temat commita do schowka",
CopyCommitDiffToClipboard: "Kopiuj różnice commita do schowka",
CopyCommitSHAToClipboard: "Kopiuj SHA commita do schowka",
CopyCommitHashToClipboard: "Kopiuj SHA commita do schowka",
CopyCommitURLToClipboard: "Kopiuj URL commita do schowka",
CopyCommitAuthorToClipboard: "Kopiuj autora commita do schowka",
CopyCommitAttributeToClipboard: "Kopiuj do schowka",

View File

@ -422,8 +422,8 @@ func RussianTranslationSet() TranslationSet {
OpenCommandLogMenu: "Открыть меню журнала команд",
ShowingGitDiff: "Показывает вывод для:",
CommitDiff: "Разница коммита",
CopyCommitShaToClipboard: "Скопировать SHA коммита в буфер обмена",
CommitSha: "SHA коммита",
CopyCommitHashToClipboard: "Скопировать SHA коммита в буфер обмена",
CommitHash: "SHA коммита",
CommitURL: "URL коммита",
CopyCommitMessageToClipboard: "Скопировать сообщение коммита в буфер обмена",
CommitMessage: "Полное сообщение коммита",
@ -579,7 +579,7 @@ func RussianTranslationSet() TranslationSet {
CopyCommitMessageToClipboard: "Скопировать сообщение коммита в буфер обмена",
CopyCommitSubjectToClipboard: "Скопировать тему коммита в буфер обмена",
CopyCommitDiffToClipboard: "Скопировать сравнения коммита в буфер обмена",
CopyCommitSHAToClipboard: "Скопировать SHA коммита в буфер обмена",
CopyCommitHashToClipboard: "Скопировать SHA коммита в буфер обмена",
CopyCommitURLToClipboard: "Скопировать URL коммита в буфер обмена",
CopyCommitAuthorToClipboard: "Скопировать автора коммита в буфер обмена",
CopyCommitAttributeToClipboard: "Скопировать в буфер обмена",

View File

@ -454,8 +454,8 @@ func traditionalChineseTranslationSet() TranslationSet {
OpenCommandLogMenu: "開啟命令記錄選單",
ShowingGitDiff: "顯示輸出:",
CommitDiff: "提交差異",
CopyCommitShaToClipboard: "複製提交 SHA 到剪貼簿",
CommitSha: "提交 SHA",
CopyCommitHashToClipboard: "複製提交 SHA 到剪貼簿",
CommitHash: "提交 SHA",
CommitURL: "提交 URL",
CopyCommitMessageToClipboard: "複製提交訊息到剪貼簿",
CommitMessage: "提交訊息",
@ -647,7 +647,7 @@ func traditionalChineseTranslationSet() TranslationSet {
CreateAnnotatedTag: "建立附註標籤",
CopyCommitMessageToClipboard: "將提交訊息複製到剪貼簿",
CopyCommitDiffToClipboard: "將提交差異複製到剪貼簿",
CopyCommitSHAToClipboard: "將提交 SHA 複製到剪貼簿",
CopyCommitHashToClipboard: "將提交 SHA 複製到剪貼簿",
CopyCommitURLToClipboard: "將提交 URL 複製到剪貼簿",
CopyCommitAuthorToClipboard: "將提交作者複製到剪貼簿",
CopyCommitAttributeToClipboard: "複製到剪貼簿",