From e5fa9e1c4afd84da9d6cabb510c13fb66ebc66f2 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Sat, 16 Mar 2024 15:48:34 +0100 Subject: [PATCH] Store full ref in Name field of update-ref commits Strip the prefix at presentation time instead. This makes it easier to find update-ref todos in order to move them up/down, or delete them. --- pkg/commands/git_commands/commit_loader.go | 2 +- pkg/gui/controllers/local_commits_controller.go | 2 +- pkg/gui/presentation/commits.go | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 7cd7f38b0..df22b91bf 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -348,7 +348,7 @@ func (self *CommitLoader) getRebasingCommits(rebaseMode enums.RebaseMode) []*mod for _, t := range todos { if t.Command == todo.UpdateRef { - t.Msg = strings.TrimPrefix(t.Ref, "refs/heads/") + t.Msg = t.Ref } else if t.Commit == "" { // Command does not have a commit associated, skip continue diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 085504662..dba00f4b6 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -282,7 +282,7 @@ func (self *LocalCommitsController) GetOnRenderToMain() func() error { utils.ResolvePlaceholderString( self.c.Tr.UpdateRefHere, map[string]string{ - "ref": commit.Name, + "ref": strings.TrimPrefix(commit.Name, "refs/heads/"), })) } else { cmdObj := self.c.Git().Commit.ShowCmdObj(commit.Sha, self.c.Modes().Filtering.GetPath()) diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index bd4057e41..611fdde8c 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -342,6 +342,9 @@ func displayCommit( } name := commit.Name + if commit.Action == todo.UpdateRef { + name = strings.TrimPrefix(name, "refs/heads/") + } if parseEmoji { name = emoji.Sprint(name) }