-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
Describe the bug
When you have GPG passphrase setup to be prompt in CLI, it will hang indefinitely when trying to reword the last commit. No input can reach the gpg prompt.
While it works when you just want to do a normal commit.
To Reproduce
Steps to reproduce the behavior:
- Have your GPG setup with passphrase, see here
- Change GPG to ask passphrase in CLI by having
pinentry-mode loopbackin~/.gnupg/gpg.conf - Maybe restart your gpg agent by doing
gpg-connect-agent reloadagent /bye - Reword the last commit in a repo by going to the Commits panel and press r on the last commit
- Type your reworded message and press enter
- See it asks for passphrase on top of lazygit TUI
Expected behavior
You should be able to enter your passphrase and submit it to GPG prompt.
Version info:
commit=v0.42.0, build date=2024-05-19T10:54:29Z, build source=binaryRelease, version=0.42.0, os=linux, arch=amd64, git version=2.45.2
Additional context
This relates #3758 and #30.
It seems like it goes through the same code path as rebasing which does not have explicit GPG support.
The line in question is in here:
lazygit/pkg/commands/git_commands/rebase.go
Lines 37 to 41 in a3560eb
| func (self *RebaseCommands) RewordCommit(commits []*models.Commit, index int, summary string, description string) error { | |
| if models.IsHeadCommit(commits, index) { | |
| // we've selected the top commit so no rebase is required | |
| return self.commit.RewordLastCommit(summary, description) | |
| } |
GPG works fine when committing normally, it goes to a different code path which can handle gpg.
lazygit/pkg/gui/controllers/helpers/working_tree_helper.go
Lines 103 to 110 in a3560eb
| func (self *WorkingTreeHelper) handleCommit(summary string, description string) error { | |
| cmdObj := self.c.Git().Commit.CommitCmdObj(summary, description) | |
| self.c.LogAction(self.c.Tr.Actions.Commit) | |
| return self.gpgHelper.WithGpgHandling(cmdObj, self.c.Tr.CommittingStatus, func() error { | |
| self.commitsHelper.OnCommitSuccess() | |
| return nil | |
| }) | |
| } |
The question is just to access gpghelper from RebaseCommands and wrap the commands using gpghelper.
Maybe I can try to figure it out this weekend or this month when I am free, could also see if I can add initial gpg support to rebasing as mentioned here.
lazygit/pkg/commands/git_commands/rebase.go
Lines 392 to 405 in a3560eb
| func (self *RebaseCommands) BeginInteractiveRebaseForCommitRange( | |
| commits []*models.Commit, start, end int, keepCommitsThatBecomeEmpty bool, | |
| ) error { | |
| if len(commits)-1 < end { | |
| return errors.New("index outside of range of commits") | |
| } | |
| // we can make this GPG thing possible it just means we need to do this in two parts: | |
| // one where we handle the possibility of a credential request, and the other | |
| // where we continue the rebase | |
| if self.config.UsingGpg() { | |
| return errors.New(self.Tr.DisabledForGPG) | |
| } | |
