diff options
author | Ryooooooga <eial5q265e5@gmail.com> | 2022-10-15 11:15:31 +0900 |
---|---|---|
committer | Ryooooooga <eial5q265e5@gmail.com> | 2022-10-16 09:12:43 +0900 |
commit | eceb3a5aa6de864f31c52016e6fd497b9b6a1214 (patch) | |
tree | a2240f25bf60b1d4277ee85e9c5603f05a3ed6aa /pkg/gui/controllers/stash_controller.go | |
parent | 8a9eefa4d275f925e149be2c05c5c6958da86f5b (diff) |
chore: refactor rename stash
Diffstat (limited to 'pkg/gui/controllers/stash_controller.go')
-rw-r--r-- | pkg/gui/controllers/stash_controller.go | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/pkg/gui/controllers/stash_controller.go b/pkg/gui/controllers/stash_controller.go index 6cd06c6d4..1e4137777 100644 --- a/pkg/gui/controllers/stash_controller.go +++ b/pkg/gui/controllers/stash_controller.go @@ -1,8 +1,6 @@ package controllers import ( - "regexp" - "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -161,23 +159,12 @@ func (self *StashController) handleRenameStashEntry(stashEntry *models.StashEntr InitialContent: stashEntry.Name, HandleConfirm: func(response string) error { self.c.LogAction(self.c.Tr.Actions.RenameStash) - output, err := self.git.Stash.Drop(stashEntry.Index) - if err != nil { - return err - } - - stashShaPattern := regexp.MustCompile(`\(([0-9a-f]+)\)`) - matches := stashShaPattern.FindStringSubmatch(output) - stashSha := "" - if len(matches) > 1 { - stashSha = matches[1] - } - - err = self.git.Stash.Store(stashSha, response) + err := self.git.Stash.Rename(stashEntry.Index, response) _ = self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH}}) if err != nil { return err } + self.context().SetSelectedLineIdx(0) // Select the renamed stash return nil }, }) |