mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-23 12:18:51 +02:00
rename sha to hash 5
This commit is contained in:
parent
dc6863b83d
commit
9cf1ca10a2
@ -76,7 +76,7 @@ func (self *BisectCommands) GetInfoForGitDir(gitDir string) *BisectInfo {
|
|||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
sha := strings.TrimSpace(string(fileContent))
|
hash := strings.TrimSpace(string(fileContent))
|
||||||
|
|
||||||
if name == info.newTerm {
|
if name == info.newTerm {
|
||||||
status = BisectStatusNew
|
status = BisectStatusNew
|
||||||
@ -86,7 +86,7 @@ func (self *BisectCommands) GetInfoForGitDir(gitDir string) *BisectInfo {
|
|||||||
status = BisectStatusSkipped
|
status = BisectStatusSkipped
|
||||||
}
|
}
|
||||||
|
|
||||||
info.statusMap[sha] = status
|
info.statusMap[hash] = status
|
||||||
}
|
}
|
||||||
|
|
||||||
currentContent, err := os.ReadFile(filepath.Join(gitDir, "BISECT_EXPECTED_REV"))
|
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()
|
cmdArgs := NewGitCmd("rev-list").Arg(newSha).ToArgv()
|
||||||
err := self.cmd.New(cmdArgs).RunAndProcessLines(func(line string) (bool, error) {
|
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 {
|
switch status {
|
||||||
case BisectStatusSkipped, BisectStatusNew:
|
case BisectStatusSkipped, BisectStatusNew:
|
||||||
candidates = append(candidates, sha)
|
candidates = append(candidates, hash)
|
||||||
return false, nil
|
return false, nil
|
||||||
case BisectStatusOld:
|
case BisectStatusOld:
|
||||||
done = true
|
done = true
|
||||||
|
@ -65,10 +65,10 @@ func (self *BranchCommands) CurrentBranchInfo() (BranchInfo, error) {
|
|||||||
for _, line := range utils.SplitLines(output) {
|
for _, line := range utils.SplitLines(output) {
|
||||||
split := strings.Split(strings.TrimRight(line, "\r\n"), "\x00")
|
split := strings.Split(strings.TrimRight(line, "\r\n"), "\x00")
|
||||||
if len(split) == 3 && split[0] == "*" {
|
if len(split) == 3 && split[0] == "*" {
|
||||||
sha := split[1]
|
hash := split[1]
|
||||||
displayName := split[2]
|
displayName := split[2]
|
||||||
return BranchInfo{
|
return BranchInfo{
|
||||||
RefName: sha,
|
RefName: hash,
|
||||||
DisplayName: displayName,
|
DisplayName: displayName,
|
||||||
DetachedHead: true,
|
DetachedHead: true,
|
||||||
}, nil
|
}, 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>'
|
// 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 {
|
func (self *CommitCommands) AddCoAuthor(hash string, author string) error {
|
||||||
message, err := self.GetCommitMessage(sha)
|
message, err := self.GetCommitMessage(hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -74,8 +74,8 @@ func AddCoAuthorToDescription(description string, author string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ResetToCommit reset to commit
|
// ResetToCommit reset to commit
|
||||||
func (self *CommitCommands) ResetToCommit(sha string, strength string, envVars []string) error {
|
func (self *CommitCommands) ResetToCommit(hash string, strength string, envVars []string) error {
|
||||||
cmdArgs := NewGitCmd("reset").Arg("--"+strength, sha).ToArgv()
|
cmdArgs := NewGitCmd("reset").Arg("--"+strength, hash).ToArgv()
|
||||||
|
|
||||||
return self.cmd.New(cmdArgs).
|
return self.cmd.New(cmdArgs).
|
||||||
// prevents git from prompting us for input which would freeze the program
|
// 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
|
return author, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitCommands) GetCommitMessageFirstLine(sha string) (string, error) {
|
func (self *CommitCommands) GetCommitMessageFirstLine(hash string) (string, error) {
|
||||||
return self.GetCommitMessagesFirstLine([]string{sha})
|
return self.GetCommitMessagesFirstLine([]string{hash})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitCommands) GetCommitMessagesFirstLine(hashes []string) (string, error) {
|
func (self *CommitCommands) GetCommitMessagesFirstLine(hashes []string) (string, error) {
|
||||||
@ -255,7 +255,7 @@ func (self *CommitCommands) AmendHeadCmdObj() oscommands.ICmdObj {
|
|||||||
return self.cmd.New(cmdArgs)
|
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
|
contextSize := self.AppState.DiffContextSize
|
||||||
|
|
||||||
extDiffCmd := self.UserConfig.Git.Paging.ExternalDiffCommand
|
extDiffCmd := self.UserConfig.Git.Paging.ExternalDiffCommand
|
||||||
@ -269,7 +269,7 @@ func (self *CommitCommands) ShowCmdObj(sha string, filterPath string) oscommands
|
|||||||
Arg("--stat").
|
Arg("--stat").
|
||||||
Arg("--decorate").
|
Arg("--decorate").
|
||||||
Arg("-p").
|
Arg("-p").
|
||||||
Arg(sha).
|
Arg(hash).
|
||||||
ArgIf(self.AppState.IgnoreWhitespaceInDiffView, "--ignore-all-space").
|
ArgIf(self.AppState.IgnoreWhitespaceInDiffView, "--ignore-all-space").
|
||||||
ArgIf(filterPath != "", "--", filterPath).
|
ArgIf(filterPath != "", "--", filterPath).
|
||||||
Dir(self.repoPaths.worktreePath).
|
Dir(self.repoPaths.worktreePath).
|
||||||
@ -278,23 +278,23 @@ func (self *CommitCommands) ShowCmdObj(sha string, filterPath string) oscommands
|
|||||||
return self.cmd.New(cmdArgs).DontLog()
|
return self.cmd.New(cmdArgs).DontLog()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Revert reverts the selected commit by sha
|
// Revert reverts the selected commit by hash
|
||||||
func (self *CommitCommands) Revert(sha string) error {
|
func (self *CommitCommands) Revert(hash string) error {
|
||||||
cmdArgs := NewGitCmd("revert").Arg(sha).ToArgv()
|
cmdArgs := NewGitCmd("revert").Arg(hash).ToArgv()
|
||||||
|
|
||||||
return self.cmd.New(cmdArgs).Run()
|
return self.cmd.New(cmdArgs).Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitCommands) RevertMerge(sha string, parentNumber int) error {
|
func (self *CommitCommands) RevertMerge(hash string, parentNumber int) error {
|
||||||
cmdArgs := NewGitCmd("revert").Arg(sha, "-m", fmt.Sprintf("%d", parentNumber)).
|
cmdArgs := NewGitCmd("revert").Arg(hash, "-m", fmt.Sprintf("%d", parentNumber)).
|
||||||
ToArgv()
|
ToArgv()
|
||||||
|
|
||||||
return self.cmd.New(cmdArgs).Run()
|
return self.cmd.New(cmdArgs).Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateFixupCommit creates a commit that fixes up a previous commit
|
// CreateFixupCommit creates a commit that fixes up a previous commit
|
||||||
func (self *CommitCommands) CreateFixupCommit(sha string) error {
|
func (self *CommitCommands) CreateFixupCommit(hash string) error {
|
||||||
cmdArgs := NewGitCmd("commit").Arg("--fixup=" + sha).ToArgv()
|
cmdArgs := NewGitCmd("commit").Arg("--fixup=" + hash).ToArgv()
|
||||||
|
|
||||||
return self.cmd.New(cmdArgs).Run()
|
return self.cmd.New(cmdArgs).Run()
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ func (self *CommitLoader) MergeRebasingCommits(commits []*models.Commit) ([]*mod
|
|||||||
return result, nil
|
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
|
// then puts them into a commit object
|
||||||
// example input:
|
// example input:
|
||||||
// 8ad01fe32fcc20f07bc6693f87aa4977c327f1e1|10 hours ago|Jesse Duffield| (HEAD -> master, tag: v0.15.2)|refresh commits when adding a tag
|
// 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),
|
findFullCommit := lo.Ternary(self.version.IsOlderThan(2, 25, 2),
|
||||||
func(sha string) *models.Commit {
|
func(hash string) *models.Commit {
|
||||||
for s, c := range fullCommits {
|
for s, c := range fullCommits {
|
||||||
if strings.HasPrefix(s, sha) {
|
if strings.HasPrefix(s, hash) {
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
func(sha string) *models.Commit {
|
func(hash string) *models.Commit {
|
||||||
return fullCommits[sha]
|
return fullCommits[hash]
|
||||||
})
|
})
|
||||||
|
|
||||||
hydratedCommits := make([]*models.Commit, 0, len(commits))
|
hydratedCommits := make([]*models.Commit, 0, len(commits))
|
||||||
@ -458,7 +458,7 @@ func setCommitMergedStatuses(ancestor string, commits []*models.Commit) {
|
|||||||
|
|
||||||
passedAncestor := false
|
passedAncestor := false
|
||||||
for i, commit := range commits {
|
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) {
|
if commit.Hash != "" && strings.HasPrefix(ancestor, commit.Hash) {
|
||||||
passedAncestor = true
|
passedAncestor = true
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ func TestCommitCommitEditorCmdObj(t *testing.T) {
|
|||||||
func TestCommitCreateFixupCommit(t *testing.T) {
|
func TestCommitCreateFixupCommit(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
testName string
|
testName string
|
||||||
sha string
|
hash string
|
||||||
runner *oscommands.FakeCmdObjRunner
|
runner *oscommands.FakeCmdObjRunner
|
||||||
test func(error)
|
test func(error)
|
||||||
}
|
}
|
||||||
@ -161,7 +161,7 @@ func TestCommitCreateFixupCommit(t *testing.T) {
|
|||||||
scenarios := []scenario{
|
scenarios := []scenario{
|
||||||
{
|
{
|
||||||
testName: "valid case",
|
testName: "valid case",
|
||||||
sha: "12345",
|
hash: "12345",
|
||||||
runner: oscommands.NewFakeRunner(t).
|
runner: oscommands.NewFakeRunner(t).
|
||||||
ExpectGitArgs([]string{"commit", "--fixup=12345"}, "", nil),
|
ExpectGitArgs([]string{"commit", "--fixup=12345"}, "", nil),
|
||||||
test: func(err error) {
|
test: func(err error) {
|
||||||
@ -174,7 +174,7 @@ func TestCommitCreateFixupCommit(t *testing.T) {
|
|||||||
s := s
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildCommitCommands(commonDeps{runner: s.runner})
|
instance := buildCommitCommands(commonDeps{runner: s.runner})
|
||||||
s.test(instance.CreateFixupCommit(s.sha))
|
s.test(instance.CreateFixupCommit(s.hash))
|
||||||
s.runner.CheckForMissingCalls()
|
s.runner.CheckForMissingCalls()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ func (self *RebaseCommands) AmendTo(commits []*models.Commit, commitIndex int) e
|
|||||||
return err
|
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()
|
cmdArgs := NewGitCmd("rev-parse").Arg("--verify", "HEAD").ToArgv()
|
||||||
fixupSha, err := self.cmd.New(cmdArgs).RunWithOutput()
|
fixupSha, err := self.cmd.New(cmdArgs).RunWithOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -47,7 +47,7 @@ func TestStashSave(t *testing.T) {
|
|||||||
func TestStashStore(t *testing.T) {
|
func TestStashStore(t *testing.T) {
|
||||||
type scenario struct {
|
type scenario struct {
|
||||||
testName string
|
testName string
|
||||||
sha string
|
hash string
|
||||||
message string
|
message string
|
||||||
expected []string
|
expected []string
|
||||||
}
|
}
|
||||||
@ -55,19 +55,19 @@ func TestStashStore(t *testing.T) {
|
|||||||
scenarios := []scenario{
|
scenarios := []scenario{
|
||||||
{
|
{
|
||||||
testName: "Non-empty message",
|
testName: "Non-empty message",
|
||||||
sha: "0123456789abcdef",
|
hash: "0123456789abcdef",
|
||||||
message: "New stash name",
|
message: "New stash name",
|
||||||
expected: []string{"stash", "store", "-m", "New stash name", "0123456789abcdef"},
|
expected: []string{"stash", "store", "-m", "New stash name", "0123456789abcdef"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testName: "Empty message",
|
testName: "Empty message",
|
||||||
sha: "0123456789abcdef",
|
hash: "0123456789abcdef",
|
||||||
message: "",
|
message: "",
|
||||||
expected: []string{"stash", "store", "0123456789abcdef"},
|
expected: []string{"stash", "store", "0123456789abcdef"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
testName: "Space message",
|
testName: "Space message",
|
||||||
sha: "0123456789abcdef",
|
hash: "0123456789abcdef",
|
||||||
message: " ",
|
message: " ",
|
||||||
expected: []string{"stash", "store", "0123456789abcdef"},
|
expected: []string{"stash", "store", "0123456789abcdef"},
|
||||||
},
|
},
|
||||||
@ -80,7 +80,7 @@ func TestStashStore(t *testing.T) {
|
|||||||
ExpectGitArgs(s.expected, "", nil)
|
ExpectGitArgs(s.expected, "", nil)
|
||||||
instance := buildStashCommands(commonDeps{runner: runner})
|
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()
|
runner.CheckForMissingCalls()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -91,9 +91,9 @@ func TestStashSha(t *testing.T) {
|
|||||||
ExpectGitArgs([]string{"rev-parse", "refs/stash@{5}"}, "14d94495194651adfd5f070590df566c11d28243\n", nil)
|
ExpectGitArgs([]string{"rev-parse", "refs/stash@{5}"}, "14d94495194651adfd5f070590df566c11d28243\n", nil)
|
||||||
instance := buildStashCommands(commonDeps{runner: runner})
|
instance := buildStashCommands(commonDeps{runner: runner})
|
||||||
|
|
||||||
sha, err := instance.Hash(5)
|
hash, err := instance.Hash(5)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "14d94495194651adfd5f070590df566c11d28243", sha)
|
assert.Equal(t, "14d94495194651adfd5f070590df566c11d28243", hash)
|
||||||
runner.CheckForMissingCalls()
|
runner.CheckForMissingCalls()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ func (self *BisectController) openMidBisectMenu(info *git_commands.BisectInfo, c
|
|||||||
// ref, because we'll be reloading our commits in that case.
|
// ref, because we'll be reloading our commits in that case.
|
||||||
waitToReselect := selectCurrentAfter && !self.c.Git().Bisect.ReachableFromStart(info)
|
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
|
// not, we're still picking the initial commits before we really start, so
|
||||||
// use the selected commit in that case.
|
// use the selected commit in that case.
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ func (self *BisectController) afterBisectMarkRefresh(selectCurrent bool, waitToR
|
|||||||
func (self *BisectController) selectCurrentBisectCommit() {
|
func (self *BisectController) selectCurrentBisectCommit() {
|
||||||
info := self.c.Git().Bisect.GetInfo()
|
info := self.c.Git().Bisect.GetInfo()
|
||||||
if info.GetCurrentHash() != "" {
|
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 {
|
for i, commit := range self.c.Model().Commits {
|
||||||
if commit.Hash == info.GetCurrentHash() {
|
if commit.Hash == info.GetCurrentHash() {
|
||||||
self.context().SetSelection(i)
|
self.context().SetSelection(i)
|
||||||
|
@ -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
|
// returns the list of commit hashes that introduced the lines which have now been deleted
|
||||||
func (self *FixupHelper) blameDeletedLines(deletedLineInfos []*deletedLineInfo) []string {
|
func (self *FixupHelper) blameDeletedLines(deletedLineInfos []*deletedLineInfo) []string {
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
shaChan := make(chan string)
|
hashChan := make(chan string)
|
||||||
|
|
||||||
for _, info := range deletedLineInfos {
|
for _, info := range deletedLineInfos {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
@ -178,19 +178,19 @@ func (self *FixupHelper) blameDeletedLines(deletedLineInfos []*deletedLineInfo)
|
|||||||
}
|
}
|
||||||
blameLines := strings.Split(strings.TrimSuffix(blameOutput, "\n"), "\n")
|
blameLines := strings.Split(strings.TrimSuffix(blameOutput, "\n"), "\n")
|
||||||
for _, line := range blameLines {
|
for _, line := range blameLines {
|
||||||
shaChan <- strings.Split(line, " ")[0]
|
hashChan <- strings.Split(line, " ")[0]
|
||||||
}
|
}
|
||||||
}(info)
|
}(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
close(shaChan)
|
close(hashChan)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
result := set.New[string]()
|
result := set.New[string]()
|
||||||
for sha := range shaChan {
|
for hash := range hashChan {
|
||||||
result.Add(sha)
|
result.Add(hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.ToSlice()
|
return result.ToSlice()
|
||||||
|
@ -299,7 +299,7 @@ func (self *RefreshHelper) determineCheckedOutBranchName() string {
|
|||||||
// In all other cases, get the branch name by asking git what branch is
|
// 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
|
// 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
|
// 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 {
|
if branchName, err := self.c.Git().Branch.CurrentBranchName(); err == nil {
|
||||||
return branchName
|
return branchName
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package marked_base_commit
|
package marked_base_commit
|
||||||
|
|
||||||
type MarkedBaseCommit struct {
|
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 {
|
func New() MarkedBaseCommit {
|
||||||
@ -9,17 +9,17 @@ func New() MarkedBaseCommit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *MarkedBaseCommit) Active() bool {
|
func (m *MarkedBaseCommit) Active() bool {
|
||||||
return m.sha != ""
|
return m.hash != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MarkedBaseCommit) Reset() {
|
func (m *MarkedBaseCommit) Reset() {
|
||||||
m.sha = ""
|
m.hash = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MarkedBaseCommit) SetHash(sha string) {
|
func (m *MarkedBaseCommit) SetHash(hash string) {
|
||||||
m.sha = sha
|
m.hash = hash
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *MarkedBaseCommit) GetHash() string {
|
func (m *MarkedBaseCommit) GetHash() string {
|
||||||
return m.sha
|
return m.hash
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,9 @@ type Pipe struct {
|
|||||||
|
|
||||||
var highlightStyle = style.FgLightWhite.SetBold()
|
var highlightStyle = style.FgLightWhite.SetBold()
|
||||||
|
|
||||||
func ContainsCommitHash(pipes []*Pipe, sha string) bool {
|
func ContainsCommitHash(pipes []*Pipe, hash string) bool {
|
||||||
for _, pipe := range pipes {
|
for _, pipe := range pipes {
|
||||||
if equalHashes(pipe.fromHash, sha) {
|
if equalHashes(pipe.fromHash, hash) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,11 +177,11 @@ func SafeTruncate(str string, limit int) string {
|
|||||||
|
|
||||||
const COMMIT_HASH_SHORT_SIZE = 8
|
const COMMIT_HASH_SHORT_SIZE = 8
|
||||||
|
|
||||||
func ShortSha(sha string) string {
|
func ShortSha(hash string) string {
|
||||||
if len(sha) < COMMIT_HASH_SHORT_SIZE {
|
if len(hash) < COMMIT_HASH_SHORT_SIZE {
|
||||||
return sha
|
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
|
// Returns comma-separated list of paths, with ellipsis if there are more than 3
|
||||||
|
@ -17,7 +17,7 @@ type Todo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// In order to change a TODO in git-rebase-todo, we need to specify the old action,
|
// 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)
|
// and later in a merge)
|
||||||
type TodoChange struct {
|
type TodoChange struct {
|
||||||
Hash string
|
Hash string
|
||||||
@ -59,8 +59,8 @@ func equalHash(a, b string) bool {
|
|||||||
|
|
||||||
func findTodo(todos []todo.Todo, todoToFind Todo) (int, bool) {
|
func findTodo(todos []todo.Todo, todoToFind Todo) (int, bool) {
|
||||||
_, idx, ok := lo.FindIndexOf(todos, func(t todo.Todo) bool {
|
_, idx, ok := lo.FindIndexOf(todos, func(t todo.Todo) bool {
|
||||||
// Comparing just the sha is not enough; we need to compare both the
|
// Comparing just the hash is not enough; we need to compare both the
|
||||||
// action and the sha, as the sha could appear multiple times (e.g. in a
|
// 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
|
// pick and later in a merge). For update-ref todos we also must compare
|
||||||
// the Ref.
|
// the Ref.
|
||||||
return t.Command == todoToFind.Action &&
|
return t.Command == todoToFind.Action &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user