diff --git a/pkg/commands/git_commands/bisect.go b/pkg/commands/git_commands/bisect.go index 61fe7a641..1c70537d9 100644 --- a/pkg/commands/git_commands/bisect.go +++ b/pkg/commands/git_commands/bisect.go @@ -76,7 +76,7 @@ func (self *BisectCommands) GetInfoForGitDir(gitDir string) *BisectInfo { return info } - sha := strings.TrimSpace(string(fileContent)) + hash := strings.TrimSpace(string(fileContent)) if name == info.newTerm { status = BisectStatusNew @@ -86,7 +86,7 @@ func (self *BisectCommands) GetInfoForGitDir(gitDir string) *BisectInfo { status = BisectStatusSkipped } - info.statusMap[sha] = status + info.statusMap[hash] = status } currentContent, err := os.ReadFile(filepath.Join(gitDir, "BISECT_EXPECTED_REV")) @@ -155,12 +155,12 @@ func (self *BisectCommands) IsDone() (bool, []string, error) { cmdArgs := NewGitCmd("rev-list").Arg(newSha).ToArgv() err := self.cmd.New(cmdArgs).RunAndProcessLines(func(line string) (bool, error) { - sha := strings.TrimSpace(line) + hash := strings.TrimSpace(line) - if status, ok := info.statusMap[sha]; ok { + if status, ok := info.statusMap[hash]; ok { switch status { case BisectStatusSkipped, BisectStatusNew: - candidates = append(candidates, sha) + candidates = append(candidates, hash) return false, nil case BisectStatusOld: done = true diff --git a/pkg/commands/git_commands/branch.go b/pkg/commands/git_commands/branch.go index 6a347b8ac..8212b29b3 100644 --- a/pkg/commands/git_commands/branch.go +++ b/pkg/commands/git_commands/branch.go @@ -65,10 +65,10 @@ func (self *BranchCommands) CurrentBranchInfo() (BranchInfo, error) { for _, line := range utils.SplitLines(output) { split := strings.Split(strings.TrimRight(line, "\r\n"), "\x00") if len(split) == 3 && split[0] == "*" { - sha := split[1] + hash := split[1] displayName := split[2] return BranchInfo{ - RefName: sha, + RefName: hash, DisplayName: displayName, DetachedHead: true, }, nil diff --git a/pkg/commands/git_commands/commit.go b/pkg/commands/git_commands/commit.go index 05ab8d36b..517be276e 100644 --- a/pkg/commands/git_commands/commit.go +++ b/pkg/commands/git_commands/commit.go @@ -39,8 +39,8 @@ func (self *CommitCommands) SetAuthor(value string) error { } // Add a commit's coauthor using Github/Gitlab Co-authored-by metadata. Value is expected to be of the form 'Name ' -func (self *CommitCommands) AddCoAuthor(sha string, author string) error { - message, err := self.GetCommitMessage(sha) +func (self *CommitCommands) AddCoAuthor(hash string, author string) error { + message, err := self.GetCommitMessage(hash) if err != nil { return err } @@ -74,8 +74,8 @@ func AddCoAuthorToDescription(description string, author string) string { } // ResetToCommit reset to commit -func (self *CommitCommands) ResetToCommit(sha string, strength string, envVars []string) error { - cmdArgs := NewGitCmd("reset").Arg("--"+strength, sha).ToArgv() +func (self *CommitCommands) ResetToCommit(hash string, strength string, envVars []string) error { + cmdArgs := NewGitCmd("reset").Arg("--"+strength, hash).ToArgv() return self.cmd.New(cmdArgs). // prevents git from prompting us for input which would freeze the program @@ -206,8 +206,8 @@ func (self *CommitCommands) GetCommitAuthor(commitHash string) (Author, error) { return author, err } -func (self *CommitCommands) GetCommitMessageFirstLine(sha string) (string, error) { - return self.GetCommitMessagesFirstLine([]string{sha}) +func (self *CommitCommands) GetCommitMessageFirstLine(hash string) (string, error) { + return self.GetCommitMessagesFirstLine([]string{hash}) } func (self *CommitCommands) GetCommitMessagesFirstLine(hashes []string) (string, error) { @@ -255,7 +255,7 @@ func (self *CommitCommands) AmendHeadCmdObj() oscommands.ICmdObj { return self.cmd.New(cmdArgs) } -func (self *CommitCommands) ShowCmdObj(sha string, filterPath string) oscommands.ICmdObj { +func (self *CommitCommands) ShowCmdObj(hash string, filterPath string) oscommands.ICmdObj { contextSize := self.AppState.DiffContextSize extDiffCmd := self.UserConfig.Git.Paging.ExternalDiffCommand @@ -269,7 +269,7 @@ func (self *CommitCommands) ShowCmdObj(sha string, filterPath string) oscommands Arg("--stat"). Arg("--decorate"). Arg("-p"). - Arg(sha). + Arg(hash). ArgIf(self.AppState.IgnoreWhitespaceInDiffView, "--ignore-all-space"). ArgIf(filterPath != "", "--", filterPath). Dir(self.repoPaths.worktreePath). @@ -278,23 +278,23 @@ func (self *CommitCommands) ShowCmdObj(sha string, filterPath string) oscommands return self.cmd.New(cmdArgs).DontLog() } -// Revert reverts the selected commit by sha -func (self *CommitCommands) Revert(sha string) error { - cmdArgs := NewGitCmd("revert").Arg(sha).ToArgv() +// Revert reverts the selected commit by hash +func (self *CommitCommands) Revert(hash string) error { + cmdArgs := NewGitCmd("revert").Arg(hash).ToArgv() return self.cmd.New(cmdArgs).Run() } -func (self *CommitCommands) RevertMerge(sha string, parentNumber int) error { - cmdArgs := NewGitCmd("revert").Arg(sha, "-m", fmt.Sprintf("%d", parentNumber)). +func (self *CommitCommands) RevertMerge(hash string, parentNumber int) error { + cmdArgs := NewGitCmd("revert").Arg(hash, "-m", fmt.Sprintf("%d", parentNumber)). ToArgv() return self.cmd.New(cmdArgs).Run() } // CreateFixupCommit creates a commit that fixes up a previous commit -func (self *CommitCommands) CreateFixupCommit(sha string) error { - cmdArgs := NewGitCmd("commit").Arg("--fixup=" + sha).ToArgv() +func (self *CommitCommands) CreateFixupCommit(hash string) error { + cmdArgs := NewGitCmd("commit").Arg("--fixup=" + hash).ToArgv() return self.cmd.New(cmdArgs).Run() } diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 7707f9999..50d9db709 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -198,7 +198,7 @@ func (self *CommitLoader) MergeRebasingCommits(commits []*models.Commit) ([]*mod return result, nil } -// extractCommitFromLine takes a line from a git log and extracts the sha, message, date, and tag if present +// extractCommitFromLine takes a line from a git log and extracts the hash, message, date, and tag if present // then puts them into a commit object // example input: // 8ad01fe32fcc20f07bc6693f87aa4977c327f1e1|10 hours ago|Jesse Duffield| (HEAD -> master, tag: v0.15.2)|refresh commits when adding a tag @@ -285,16 +285,16 @@ func (self *CommitLoader) getHydratedRebasingCommits(rebaseMode enums.RebaseMode } findFullCommit := lo.Ternary(self.version.IsOlderThan(2, 25, 2), - func(sha string) *models.Commit { + func(hash string) *models.Commit { for s, c := range fullCommits { - if strings.HasPrefix(s, sha) { + if strings.HasPrefix(s, hash) { return c } } return nil }, - func(sha string) *models.Commit { - return fullCommits[sha] + func(hash string) *models.Commit { + return fullCommits[hash] }) hydratedCommits := make([]*models.Commit, 0, len(commits)) @@ -458,7 +458,7 @@ func setCommitMergedStatuses(ancestor string, commits []*models.Commit) { passedAncestor := false for i, commit := range commits { - // some commits aren't really commits and don't have sha's, such as the update-ref todo + // some commits aren't really commits and don't have hashes, such as the update-ref todo if commit.Hash != "" && strings.HasPrefix(ancestor, commit.Hash) { passedAncestor = true } diff --git a/pkg/commands/git_commands/commit_test.go b/pkg/commands/git_commands/commit_test.go index 4dd9322f1..43a8d0556 100644 --- a/pkg/commands/git_commands/commit_test.go +++ b/pkg/commands/git_commands/commit_test.go @@ -153,7 +153,7 @@ func TestCommitCommitEditorCmdObj(t *testing.T) { func TestCommitCreateFixupCommit(t *testing.T) { type scenario struct { testName string - sha string + hash string runner *oscommands.FakeCmdObjRunner test func(error) } @@ -161,7 +161,7 @@ func TestCommitCreateFixupCommit(t *testing.T) { scenarios := []scenario{ { testName: "valid case", - sha: "12345", + hash: "12345", runner: oscommands.NewFakeRunner(t). ExpectGitArgs([]string{"commit", "--fixup=12345"}, "", nil), test: func(err error) { @@ -174,7 +174,7 @@ func TestCommitCreateFixupCommit(t *testing.T) { s := s t.Run(s.testName, func(t *testing.T) { instance := buildCommitCommands(commonDeps{runner: s.runner}) - s.test(instance.CreateFixupCommit(s.sha)) + s.test(instance.CreateFixupCommit(s.hash)) s.runner.CheckForMissingCalls() }) } diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go index 34a6c8661..50cadd8a3 100644 --- a/pkg/commands/git_commands/rebase.go +++ b/pkg/commands/git_commands/rebase.go @@ -288,7 +288,7 @@ func (self *RebaseCommands) AmendTo(commits []*models.Commit, commitIndex int) e return err } - // Get the sha of the commit we just created + // Get the hash of the commit we just created cmdArgs := NewGitCmd("rev-parse").Arg("--verify", "HEAD").ToArgv() fixupSha, err := self.cmd.New(cmdArgs).RunWithOutput() if err != nil { diff --git a/pkg/commands/git_commands/stash_test.go b/pkg/commands/git_commands/stash_test.go index 3f112cd0c..ad44d7239 100644 --- a/pkg/commands/git_commands/stash_test.go +++ b/pkg/commands/git_commands/stash_test.go @@ -47,7 +47,7 @@ func TestStashSave(t *testing.T) { func TestStashStore(t *testing.T) { type scenario struct { testName string - sha string + hash string message string expected []string } @@ -55,19 +55,19 @@ func TestStashStore(t *testing.T) { scenarios := []scenario{ { testName: "Non-empty message", - sha: "0123456789abcdef", + hash: "0123456789abcdef", message: "New stash name", expected: []string{"stash", "store", "-m", "New stash name", "0123456789abcdef"}, }, { testName: "Empty message", - sha: "0123456789abcdef", + hash: "0123456789abcdef", message: "", expected: []string{"stash", "store", "0123456789abcdef"}, }, { testName: "Space message", - sha: "0123456789abcdef", + hash: "0123456789abcdef", message: " ", expected: []string{"stash", "store", "0123456789abcdef"}, }, @@ -80,7 +80,7 @@ func TestStashStore(t *testing.T) { ExpectGitArgs(s.expected, "", nil) instance := buildStashCommands(commonDeps{runner: runner}) - assert.NoError(t, instance.Store(s.sha, s.message)) + assert.NoError(t, instance.Store(s.hash, s.message)) runner.CheckForMissingCalls() }) } @@ -91,9 +91,9 @@ func TestStashSha(t *testing.T) { ExpectGitArgs([]string{"rev-parse", "refs/stash@{5}"}, "14d94495194651adfd5f070590df566c11d28243\n", nil) instance := buildStashCommands(commonDeps{runner: runner}) - sha, err := instance.Hash(5) + hash, err := instance.Hash(5) assert.NoError(t, err) - assert.Equal(t, "14d94495194651adfd5f070590df566c11d28243", sha) + assert.Equal(t, "14d94495194651adfd5f070590df566c11d28243", hash) runner.CheckForMissingCalls() } diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index 4fc2ec772..ddd2f9735 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -74,7 +74,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c // ref, because we'll be reloading our commits in that case. waitToReselect := selectCurrentAfter && !self.c.Git().Bisect.ReachableFromStart(info) - // If we have a current sha already, then we always want to use that one. If + // If we have a current hash already, then we always want to use that one. If // not, we're still picking the initial commits before we really start, so // use the selected commit in that case. @@ -285,7 +285,7 @@ func (self *BisectController) afterBisectMarkRefresh(selectCurrent bool, waitToR func (self *BisectController) selectCurrentBisectCommit() { info := self.c.Git().Bisect.GetInfo() if info.GetCurrentHash() != "" { - // find index of commit with that sha, move cursor to that. + // find index of commit with that hash, move cursor to that. for i, commit := range self.c.Model().Commits { if commit.Hash == info.GetCurrentHash() { self.context().SetSelection(i) diff --git a/pkg/gui/controllers/helpers/fixup_helper.go b/pkg/gui/controllers/helpers/fixup_helper.go index 5be1ba83f..79104120e 100644 --- a/pkg/gui/controllers/helpers/fixup_helper.go +++ b/pkg/gui/controllers/helpers/fixup_helper.go @@ -164,7 +164,7 @@ func (self *FixupHelper) parseDiff(diff string) ([]*deletedLineInfo, bool) { // returns the list of commit hashes that introduced the lines which have now been deleted func (self *FixupHelper) blameDeletedLines(deletedLineInfos []*deletedLineInfo) []string { var wg sync.WaitGroup - shaChan := make(chan string) + hashChan := make(chan string) for _, info := range deletedLineInfos { wg.Add(1) @@ -178,19 +178,19 @@ func (self *FixupHelper) blameDeletedLines(deletedLineInfos []*deletedLineInfo) } blameLines := strings.Split(strings.TrimSuffix(blameOutput, "\n"), "\n") for _, line := range blameLines { - shaChan <- strings.Split(line, " ")[0] + hashChan <- strings.Split(line, " ")[0] } }(info) } go func() { wg.Wait() - close(shaChan) + close(hashChan) }() result := set.New[string]() - for sha := range shaChan { - result.Add(sha) + for hash := range hashChan { + result.Add(hash) } return result.ToSlice() diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 34e390bde..4e1a9fc54 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -299,7 +299,7 @@ func (self *RefreshHelper) determineCheckedOutBranchName() string { // In all other cases, get the branch name by asking git what branch is // checked out. Note that if we're on a detached head (for reasons other // than rebasing or bisecting, i.e. it was explicitly checked out), then - // this will return its sha. + // this will return its hash. if branchName, err := self.c.Git().Branch.CurrentBranchName(); err == nil { return branchName } diff --git a/pkg/gui/modes/marked_base_commit/marked_base_commit.go b/pkg/gui/modes/marked_base_commit/marked_base_commit.go index 3a239235d..ace1e35d0 100644 --- a/pkg/gui/modes/marked_base_commit/marked_base_commit.go +++ b/pkg/gui/modes/marked_base_commit/marked_base_commit.go @@ -1,7 +1,7 @@ package marked_base_commit type MarkedBaseCommit struct { - sha string // the sha of the commit used as a rebase base commit; empty string when unset + hash string // the hash of the commit used as a rebase base commit; empty string when unset } func New() MarkedBaseCommit { @@ -9,17 +9,17 @@ func New() MarkedBaseCommit { } func (m *MarkedBaseCommit) Active() bool { - return m.sha != "" + return m.hash != "" } func (m *MarkedBaseCommit) Reset() { - m.sha = "" + m.hash = "" } -func (m *MarkedBaseCommit) SetHash(sha string) { - m.sha = sha +func (m *MarkedBaseCommit) SetHash(hash string) { + m.hash = hash } func (m *MarkedBaseCommit) GetHash() string { - return m.sha + return m.hash } diff --git a/pkg/gui/presentation/graph/graph.go b/pkg/gui/presentation/graph/graph.go index e13f6916a..8133fd9b6 100644 --- a/pkg/gui/presentation/graph/graph.go +++ b/pkg/gui/presentation/graph/graph.go @@ -32,9 +32,9 @@ type Pipe struct { var highlightStyle = style.FgLightWhite.SetBold() -func ContainsCommitHash(pipes []*Pipe, sha string) bool { +func ContainsCommitHash(pipes []*Pipe, hash string) bool { for _, pipe := range pipes { - if equalHashes(pipe.fromHash, sha) { + if equalHashes(pipe.fromHash, hash) { return true } } diff --git a/pkg/utils/formatting.go b/pkg/utils/formatting.go index 1f5d47db6..ffc530068 100644 --- a/pkg/utils/formatting.go +++ b/pkg/utils/formatting.go @@ -177,11 +177,11 @@ func SafeTruncate(str string, limit int) string { const COMMIT_HASH_SHORT_SIZE = 8 -func ShortSha(sha string) string { - if len(sha) < COMMIT_HASH_SHORT_SIZE { - return sha +func ShortSha(hash string) string { + if len(hash) < COMMIT_HASH_SHORT_SIZE { + return hash } - return sha[:COMMIT_HASH_SHORT_SIZE] + return hash[:COMMIT_HASH_SHORT_SIZE] } // Returns comma-separated list of paths, with ellipsis if there are more than 3 diff --git a/pkg/utils/rebase_todo.go b/pkg/utils/rebase_todo.go index ee5e3d656..6062d6785 100644 --- a/pkg/utils/rebase_todo.go +++ b/pkg/utils/rebase_todo.go @@ -17,7 +17,7 @@ type Todo struct { } // In order to change a TODO in git-rebase-todo, we need to specify the old action, -// because sometimes the same sha appears multiple times in the file (e.g. in a pick +// because sometimes the same hash appears multiple times in the file (e.g. in a pick // and later in a merge) type TodoChange struct { Hash string @@ -59,8 +59,8 @@ func equalHash(a, b string) bool { func findTodo(todos []todo.Todo, todoToFind Todo) (int, bool) { _, idx, ok := lo.FindIndexOf(todos, func(t todo.Todo) bool { - // Comparing just the sha is not enough; we need to compare both the - // action and the sha, as the sha could appear multiple times (e.g. in a + // Comparing just the hash is not enough; we need to compare both the + // action and the hash, as the hash could appear multiple times (e.g. in a // pick and later in a merge). For update-ref todos we also must compare // the Ref. return t.Command == todoToFind.Action &&