diff options
Diffstat (limited to 'pkg/app')
-rw-r--r-- | pkg/app/daemon/daemon.go | 40 | ||||
-rw-r--r-- | pkg/app/daemon/rebase.go | 7 | ||||
-rw-r--r-- | pkg/app/entry_point.go | 15 |
3 files changed, 52 insertions, 10 deletions
diff --git a/pkg/app/daemon/daemon.go b/pkg/app/daemon/daemon.go index e815b6e82..045491fce 100644 --- a/pkg/app/daemon/daemon.go +++ b/pkg/app/daemon/daemon.go @@ -8,11 +8,11 @@ import ( "os/exec" "strconv" - "github.com/fsmiamoto/git-todo-parser/todo" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" + "github.com/stefanhaller/git-todo-parser/todo" ) // Sometimes lazygit will be invoked in daemon mode from a parent lazygit process. @@ -33,6 +33,7 @@ const ( DaemonKindUnknown DaemonKind = iota DaemonKindExitImmediately + DaemonKindRemoveUpdateRefsForCopiedBranch DaemonKindCherryPick DaemonKindMoveTodosUp DaemonKindMoveTodosDown @@ -53,14 +54,15 @@ func getInstruction() Instruction { jsonData := os.Getenv(DaemonInstructionEnvKey) mapping := map[DaemonKind]func(string) Instruction{ - DaemonKindExitImmediately: deserializeInstruction[*ExitImmediatelyInstruction], - DaemonKindCherryPick: deserializeInstruction[*CherryPickCommitsInstruction], - DaemonKindChangeTodoActions: deserializeInstruction[*ChangeTodoActionsInstruction], - DaemonKindMoveFixupCommitDown: deserializeInstruction[*MoveFixupCommitDownInstruction], - DaemonKindMoveTodosUp: deserializeInstruction[*MoveTodosUpInstruction], - DaemonKindMoveTodosDown: deserializeInstruction[*MoveTodosDownInstruction], - DaemonKindInsertBreak: deserializeInstruction[*InsertBreakInstruction], - DaemonKindWriteRebaseTodo: deserializeInstruction[*WriteRebaseTodoInstruction], + DaemonKindExitImmediately: deserializeInstruction[*ExitImmediatelyInstruction], + DaemonKindRemoveUpdateRefsForCopiedBranch: deserializeInstruction[*RemoveUpdateRefsForCopiedBranchInstruction], + DaemonKindCherryPick: deserializeInstruction[*CherryPickCommitsInstruction], + DaemonKindChangeTodoActions: deserializeInstruction[*ChangeTodoActionsInstruction], + DaemonKindMoveFixupCommitDown: deserializeInstruction[*MoveFixupCommitDownInstruction], + DaemonKindMoveTodosUp: deserializeInstruction[*MoveTodosUpInstruction], + DaemonKindMoveTodosDown: deserializeInstruction[*MoveTodosDownInstruction], + DaemonKindInsertBreak: deserializeInstruction[*InsertBreakInstruction], + DaemonKindWriteRebaseTodo: deserializeInstruction[*WriteRebaseTodoInstruction], } return mapping[getDaemonKind()](jsonData) @@ -157,6 +159,26 @@ func NewExitImmediatelyInstruction() Instruction { return &ExitImmediatelyInstruction{} } +type RemoveUpdateRefsForCopiedBranchInstruction struct{} + +func (self *RemoveUpdateRefsForCopiedBranchInstruction) Kind() DaemonKind { + return DaemonKindRemoveUpdateRefsForCopiedBranch +} + +func (self *RemoveUpdateRefsForCopiedBranchInstruction) SerializedInstructions() string { + return serializeInstruction(self) +} + +func (self *RemoveUpdateRefsForCopiedBranchInstruction) run(common *common.Common) error { + return handleInteractiveRebase(common, func(path string) error { + return nil + }) +} + +func NewRemoveUpdateRefsForCopiedBranchInstruction() Instruction { + return &RemoveUpdateRefsForCopiedBranchInstruction{} +} + type CherryPickCommitsInstruction struct { Todo string } diff --git a/pkg/app/daemon/rebase.go b/pkg/app/daemon/rebase.go index 0ca323c7d..8cc16d3b1 100644 --- a/pkg/app/daemon/rebase.go +++ b/pkg/app/daemon/rebase.go @@ -5,11 +5,12 @@ import ( "path/filepath" "strings" - "github.com/fsmiamoto/git-todo-parser/todo" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/common" "github.com/jesseduffield/lazygit/pkg/env" + "github.com/jesseduffield/lazygit/pkg/utils" "github.com/samber/lo" + "github.com/stefanhaller/git-todo-parser/todo" ) type TodoLine struct { @@ -44,6 +45,10 @@ func handleInteractiveRebase(common *common.Common, f func(path string) error) e 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 diff --git a/pkg/app/entry_point.go b/pkg/app/entry_point.go index baeb43ae5..96f6176c7 100644 --- a/pkg/app/entry_point.go +++ b/pkg/app/entry_point.go @@ -4,6 +4,8 @@ import ( "bytes" "fmt" "log" + "net/http" + _ "net/http/pprof" "os" "os/exec" "path/filepath" @@ -30,6 +32,7 @@ type cliArgs struct { PrintVersionInfo bool Debug bool TailLogs bool + Profile bool PrintDefaultConfig bool PrintConfigDir bool UseConfigDir string @@ -145,6 +148,14 @@ func Start(buildInfo *BuildInfo, integrationTest integrationTypes.IntegrationTes return } + if cliArgs.Profile { + go func() { + if err := http.ListenAndServe("localhost:6060", nil); err != nil { + log.Fatal(err) + } + }() + } + parsedGitArg := parseGitArg(cliArgs.GitArg) Run(appConfig, common, appTypes.NewStartArgs(cliArgs.FilterPath, parsedGitArg, integrationTest)) @@ -171,6 +182,9 @@ func parseCliArgsAndEnvVars() *cliArgs { tailLogs := false flaggy.Bool(&tailLogs, "l", "logs", "Tail lazygit logs (intended to be used when `lazygit --debug` is called in a separate terminal tab)") + profile := false + flaggy.Bool(&profile, "", "profile", "Start the profiler and serve it on http port 6060. See CONTRIBUTING.md for more info.") + printDefaultConfig := false flaggy.Bool(&printDefaultConfig, "c", "config", "Print the default config") @@ -202,6 +216,7 @@ func parseCliArgsAndEnvVars() *cliArgs { PrintVersionInfo: printVersionInfo, Debug: debug, TailLogs: tailLogs, + Profile: profile, PrintDefaultConfig: printDefaultConfig, PrintConfigDir: printConfigDir, UseConfigDir: useConfigDir, |