mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-08-06 11:02:41 +03:00
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package daemon
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"github.com/jesseduffield/lazygit/pkg/common"
|
|
"github.com/jesseduffield/lazygit/pkg/env"
|
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
|
"github.com/stefanhaller/git-todo-parser/todo"
|
|
)
|
|
|
|
type ChangeTodoAction struct {
|
|
Hash string
|
|
NewAction todo.TodoCommand
|
|
}
|
|
|
|
func handleInteractiveRebase(common *common.Common, f func(path string) error) error {
|
|
common.Log.Info("Lazygit invoked as interactive rebase demon")
|
|
common.Log.Info("args: ", os.Args)
|
|
path := os.Args[1]
|
|
|
|
if strings.HasSuffix(path, "git-rebase-todo") {
|
|
err := utils.RemoveUpdateRefsForCopiedBranch(path, getCommentChar())
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return f(path)
|
|
} else if strings.HasSuffix(path, filepath.Join(gitDir(), "COMMIT_EDITMSG")) { // TODO: test
|
|
// if we are rebasing and squashing, we'll see a COMMIT_EDITMSG
|
|
// but in this case we don't need to edit it, so we'll just return
|
|
} else {
|
|
common.Log.Info("Lazygit demon did not match on any use cases")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func gitDir() string {
|
|
dir := env.GetGitDirEnv()
|
|
if dir == "" {
|
|
return ".git"
|
|
}
|
|
return dir
|
|
}
|