mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-17 00:18:05 +02:00
rename sha to hash 5
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 <Email>'
|
||||
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()
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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()
|
||||
})
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user