summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2024-03-16 15:51:14 +0100
committerStefan Haller <stefan@haller-berlin.de>2024-03-16 22:01:03 +0100
commitbd975a8dcb4205998e9c2594351c0977ad2b6775 (patch)
tree80525f9bdda496e1e92f0ec039fa9547a42ed475 /pkg/commands
parente5fa9e1c4afd84da9d6cabb510c13fb66ebc66f2 (diff)
Allow moving update-ref todos up/down
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git_commands/rebase.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go
index 0bcfa5f67..c628ad414 100644
--- a/pkg/commands/git_commands/rebase.go
+++ b/pkg/commands/git_commands/rebase.go
@@ -272,6 +272,14 @@ func (self *RebaseCommands) AmendTo(commits []*models.Commit, commitIndex int) e
}).Run()
}
+func todoFromCommit(commit *models.Commit) utils.Todo {
+ if commit.Action == todo.UpdateRef {
+ return utils.Todo{Ref: commit.Name, Action: commit.Action}
+ } else {
+ return utils.Todo{Sha: commit.Sha, Action: commit.Action}
+ }
+}
+
// Sets the action for the given commits in the git-rebase-todo file
func (self *RebaseCommands) EditRebaseTodo(commits []*models.Commit, action todo.TodoCommand) error {
commitsWithAction := lo.Map(commits, func(commit *models.Commit, _ int) utils.TodoChange {
@@ -292,10 +300,7 @@ func (self *RebaseCommands) EditRebaseTodo(commits []*models.Commit, action todo
func (self *RebaseCommands) MoveTodosDown(commits []*models.Commit) error {
fileName := filepath.Join(self.repoPaths.WorktreeGitDirPath(), "rebase-merge/git-rebase-todo")
todosToMove := lo.Map(commits, func(commit *models.Commit, _ int) utils.Todo {
- return utils.Todo{
- Sha: commit.Sha,
- Action: commit.Action,
- }
+ return todoFromCommit(commit)
})
return utils.MoveTodosDown(fileName, todosToMove, self.config.GetCoreCommentChar())
@@ -304,10 +309,7 @@ func (self *RebaseCommands) MoveTodosDown(commits []*models.Commit) error {
func (self *RebaseCommands) MoveTodosUp(commits []*models.Commit) error {
fileName := filepath.Join(self.repoPaths.WorktreeGitDirPath(), "rebase-merge/git-rebase-todo")
todosToMove := lo.Map(commits, func(commit *models.Commit, _ int) utils.Todo {
- return utils.Todo{
- Sha: commit.Sha,
- Action: commit.Action,
- }
+ return todoFromCommit(commit)
})
return utils.MoveTodosUp(fileName, todosToMove, self.config.GetCoreCommentChar())