mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02:00 
			
		
		
		
	Implement "edit commit" in terms of the new EditRebase function
This commit is contained in:
		| @@ -127,20 +127,6 @@ func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, index in | |||||||
| 	}).Run() | 	}).Run() | ||||||
| } | } | ||||||
|  |  | ||||||
| func (self *RebaseCommands) InteractiveRebaseBreakAfter(commits []*models.Commit, index int) error { |  | ||||||
| 	todo, sha, err := self.BuildSingleActionTodo(commits, index-1, "pick") |  | ||||||
| 	if err != nil { |  | ||||||
| 		return err |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	todo = append(todo, TodoLine{Action: "break", Commit: nil}) |  | ||||||
| 	return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ |  | ||||||
| 		baseShaOrRoot:  sha, |  | ||||||
| 		todoLines:      todo, |  | ||||||
| 		overrideEditor: true, |  | ||||||
| 	}).Run() |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func (self *RebaseCommands) EditRebase(branchRef string) error { | func (self *RebaseCommands) EditRebase(branchRef string) error { | ||||||
| 	commands := []TodoLine{{Action: "break"}} | 	commands := []TodoLine{{Action: "break"}} | ||||||
| 	return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ | 	return self.PrepareInteractiveRebaseCommand(PrepareInteractiveRebaseCommandOpts{ | ||||||
|   | |||||||
| @@ -301,7 +301,7 @@ func (self *LocalCommitsController) edit(commit *models.Commit) error { | |||||||
|  |  | ||||||
| 	return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func() error { | 	return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func() error { | ||||||
| 		self.c.LogAction(self.c.Tr.Actions.EditCommit) | 		self.c.LogAction(self.c.Tr.Actions.EditCommit) | ||||||
| 		err := self.git.Rebase.InteractiveRebaseBreakAfter(self.model.Commits, self.context().GetSelectedLineIdx()) | 		err := self.git.Rebase.EditRebase(commit.Sha) | ||||||
| 		return self.helpers.MergeAndRebase.CheckMergeOrRebase(err) | 		return self.helpers.MergeAndRebase.CheckMergeOrRebase(err) | ||||||
| 	}) | 	}) | ||||||
| } | } | ||||||
|   | |||||||
| @@ -30,17 +30,8 @@ var DropTodoCommitWithUpdateRef = NewIntegrationTest(NewIntegrationTestArgs{ | |||||||
| 				Contains("commit 02"), | 				Contains("commit 02"), | ||||||
| 				Contains("commit 01"), | 				Contains("commit 01"), | ||||||
| 			). | 			). | ||||||
| 			// Once "e" is fixed we can just hit "e", but for now we need to | 			NavigateToLine(Contains("commit 01")). | ||||||
| 			// manually do a command-line rebase | 			Press(keys.Universal.Edit). | ||||||
| 			// NavigateToLine(Contains("commit 01")). |  | ||||||
| 			// Press(keys.Universal.Edit). |  | ||||||
| 			Tap(func() { |  | ||||||
| 				t.GlobalPress(keys.Universal.ExecuteCustomCommand) |  | ||||||
| 				t.ExpectPopup().Prompt(). |  | ||||||
| 					Title(Equals("Custom Command:")). |  | ||||||
| 					Type(`git -c core.editor="perl -i -lpe 'print \"break\" if $.==1'" rebase -i HEAD~5`). |  | ||||||
| 					Confirm() |  | ||||||
| 			}). |  | ||||||
| 			Focus(). | 			Focus(). | ||||||
| 			Lines( | 			Lines( | ||||||
| 				Contains("pick").Contains("(*) commit 06"), | 				Contains("pick").Contains("(*) commit 06"), | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user