1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-12-24 00:21:22 +02:00

[SQUASHED] fixup-upwards

This commit is contained in:
Stefan Haller
2025-05-11 14:03:40 +02:00
parent 5d30409f33
commit 9caed72fc9
9 changed files with 63 additions and 33 deletions

View File

@@ -320,6 +320,7 @@ func (self *CommitLoader) getHydratedTodoCommits(hashPool *utils.StringPool, tod
hydratedCommits = append(hydratedCommits, rebasingCommit)
} else if commit := findFullCommit(rebasingCommit.Hash()); commit != nil {
commit.Action = rebasingCommit.Action
commit.FixupFlag = rebasingCommit.FixupFlag
commit.Status = rebasingCommit.Status
hydratedCommits = append(hydratedCommits, commit)
}
@@ -366,10 +367,11 @@ func (self *CommitLoader) getRebasingCommits(hashPool *utils.StringPool, addConf
continue
}
commits = utils.Prepend(commits, models.NewCommit(hashPool, models.NewCommitOpts{
Hash: t.Commit,
Name: t.Msg,
Status: models.StatusRebasing,
Action: t.Command,
Hash: t.Commit,
Name: t.Msg,
Status: models.StatusRebasing,
Action: t.Command,
FixupFlag: t.Command == todo.Fixup && t.Flag == "-C",
}))
}

View File

@@ -137,7 +137,7 @@ func (self *RebaseCommands) MoveCommitsUp(commits []*models.Commit, startIdx int
}).Run()
}
func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, startIdx int, endIdx int, action todo.TodoCommand) error {
func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, startIdx int, endIdx int, action todo.TodoCommand, flag string) error {
baseIndex := endIdx + 1
if action == todo.Squash || action == todo.Fixup {
baseIndex++
@@ -149,6 +149,7 @@ func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, startIdx
return daemon.ChangeTodoAction{
Hash: commit.Hash(),
NewAction: action,
NewFlag: flag,
}, !commit.IsMerge()
})
@@ -331,11 +332,12 @@ func todoFromCommit(commit *models.Commit) utils.Todo {
}
// Sets the action for the given commits in the git-rebase-todo file
func (self *RebaseCommands) EditRebaseTodo(commits []*models.Commit, action todo.TodoCommand) error {
func (self *RebaseCommands) EditRebaseTodo(commits []*models.Commit, action todo.TodoCommand, flag string) error {
commitsWithAction := lo.Map(commits, func(commit *models.Commit, _ int) utils.TodoChange {
return utils.TodoChange{
Hash: commit.Hash(),
NewAction: action,
NewFlag: flag,
}
})

View File

@@ -56,6 +56,7 @@ type Commit struct {
Status CommitStatus
Action todo.TodoCommand
FixupFlag bool // Only used for todo.Fixup action: true if the `-C` flag is set
Divergence Divergence // set to DivergenceNone unless we are showing the divergence view
}
@@ -64,6 +65,7 @@ type NewCommitOpts struct {
Name string
Status CommitStatus
Action todo.TodoCommand
FixupFlag bool
Tags []string
ExtraInfo string
AuthorName string
@@ -79,6 +81,7 @@ func NewCommit(hashPool *utils.StringPool, opts NewCommitOpts) *Commit {
Name: opts.Name,
Status: opts.Status,
Action: opts.Action,
FixupFlag: opts.FixupFlag,
Tags: opts.Tags,
ExtraInfo: opts.ExtraInfo,
AuthorName: opts.AuthorName,