mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-08 23:56:15 +02:00
Fix rewording signed commits when the log.showsignature git config is true (#3431)
- **PR Description** For people who have the log.showsignature git config set to true, trying to reword a signed commit would put the signature verification into the subject field and the commit subject into the description field of the commit message panel. Amending commits, adding co-authors to a commit, and copying a commit message to the clipboard would all be broken in a similar way. Slightly related is #1911, but back then it was more about performance than wrong behavior, it seems. Fixes #3425.
This commit is contained in:
commit
ce9cdd8d78
@ -158,6 +158,7 @@ func (self *CommitCommands) signoffFlag() string {
|
|||||||
func (self *CommitCommands) GetCommitMessage(commitSha string) (string, error) {
|
func (self *CommitCommands) GetCommitMessage(commitSha string) (string, error) {
|
||||||
cmdArgs := NewGitCmd("log").
|
cmdArgs := NewGitCmd("log").
|
||||||
Arg("--format=%B", "--max-count=1", commitSha).
|
Arg("--format=%B", "--max-count=1", commitSha).
|
||||||
|
Config("log.showsignature=false").
|
||||||
ToArgv()
|
ToArgv()
|
||||||
|
|
||||||
message, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
message, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
||||||
@ -167,6 +168,7 @@ func (self *CommitCommands) GetCommitMessage(commitSha string) (string, error) {
|
|||||||
func (self *CommitCommands) GetCommitSubject(commitSha string) (string, error) {
|
func (self *CommitCommands) GetCommitSubject(commitSha string) (string, error) {
|
||||||
cmdArgs := NewGitCmd("log").
|
cmdArgs := NewGitCmd("log").
|
||||||
Arg("--format=%s", "--max-count=1", commitSha).
|
Arg("--format=%s", "--max-count=1", commitSha).
|
||||||
|
Config("log.showsignature=false").
|
||||||
ToArgv()
|
ToArgv()
|
||||||
|
|
||||||
subject, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
subject, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
||||||
|
@ -337,7 +337,7 @@ func TestGetCommitMsg(t *testing.T) {
|
|||||||
s := s
|
s := s
|
||||||
t.Run(s.testName, func(t *testing.T) {
|
t.Run(s.testName, func(t *testing.T) {
|
||||||
instance := buildCommitCommands(commonDeps{
|
instance := buildCommitCommands(commonDeps{
|
||||||
runner: oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"log", "--format=%B", "--max-count=1", "deadbeef"}, s.input, nil),
|
runner: oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"-c", "log.showsignature=false", "log", "--format=%B", "--max-count=1", "deadbeef"}, s.input, nil),
|
||||||
})
|
})
|
||||||
|
|
||||||
output, err := instance.GetCommitMessage("deadbeef")
|
output, err := instance.GetCommitMessage("deadbeef")
|
||||||
@ -358,14 +358,14 @@ func TestGetCommitMessageFromHistory(t *testing.T) {
|
|||||||
scenarios := []scenario{
|
scenarios := []scenario{
|
||||||
{
|
{
|
||||||
"Empty message",
|
"Empty message",
|
||||||
oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"log", "-1", "--skip=2", "--pretty=%H"}, "", nil).ExpectGitArgs([]string{"log", "--format=%B", "--max-count=1"}, "", nil),
|
oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"log", "-1", "--skip=2", "--pretty=%H"}, "", nil).ExpectGitArgs([]string{"-c", "log.showsignature=false", "log", "--format=%B", "--max-count=1"}, "", nil),
|
||||||
func(output string, err error) {
|
func(output string, err error) {
|
||||||
assert.Error(t, err)
|
assert.Error(t, err)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Default case to retrieve a commit in history",
|
"Default case to retrieve a commit in history",
|
||||||
oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"log", "-1", "--skip=2", "--pretty=%H"}, "sha3 \n", nil).ExpectGitArgs([]string{"log", "--format=%B", "--max-count=1", "sha3"}, `use generics to DRY up context code`, nil),
|
oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"log", "-1", "--skip=2", "--pretty=%H"}, "sha3 \n", nil).ExpectGitArgs([]string{"-c", "log.showsignature=false", "log", "--format=%B", "--max-count=1", "sha3"}, `use generics to DRY up context code`, nil),
|
||||||
func(output string, err error) {
|
func(output string, err error) {
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, "use generics to DRY up context code", output)
|
assert.Equal(t, "use generics to DRY up context code", output)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user