Skip to content

Commit a24189b

Browse files
authored
Prefill the commit subject with the skipHook prefix when pressing w (#4456)
We removed prefilling the skipHook prefix in b102646 (#4374) with the intention of making it clearer that using the prefix in normal commits and typing `w` to skip hooks are now two independent features. It turns out that some people liked it with prefilling the prefix and perceive it as a regression, so put it back in. But only if we don't have a preserved message; this is an important use case, when you try to make a normal commit, the hook fails, and then you want to make the same commit with skipping the hook, but with the same message that you already typed.
2 parents 3916549 + ced7090 commit a24189b

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

pkg/gui/controllers/helpers/working_tree_helper.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,13 @@ func (self *WorkingTreeHelper) HandleCommitEditorPress() error {
139139
}
140140

141141
func (self *WorkingTreeHelper) HandleWIPCommitPress() error {
142-
return self.HandleCommitPressWithMessage("", true)
142+
var initialMessage string
143+
preservedMessage := self.c.Contexts().CommitMessage.GetPreservedMessageAndLogError()
144+
if preservedMessage == "" {
145+
// Use the skipHook prefix only if we don't have a preserved message
146+
initialMessage = self.c.UserConfig().Git.SkipHookPrefix
147+
}
148+
return self.HandleCommitPressWithMessage(initialMessage, true)
143149
}
144150

145151
func (self *WorkingTreeHelper) HandleCommitPress() error {

pkg/integration/tests/commit/commit_wip_with_prefix.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ var CommitWipWithPrefix = NewIntegrationTest(NewIntegrationTestArgs{
3232

3333
t.ExpectPopup().CommitMessagePanel().
3434
Title(Equals("Commit summary")).
35-
Type("foo").
35+
InitialText(Equals("WIP")).
36+
Type(" foo").
3637
Cancel()
3738

3839
t.Views().Files().
@@ -41,7 +42,7 @@ var CommitWipWithPrefix = NewIntegrationTest(NewIntegrationTestArgs{
4142

4243
t.ExpectPopup().CommitMessagePanel().
4344
Title(Equals("Commit summary")).
44-
InitialText(Equals("foo")).
45+
InitialText(Equals("WIP foo")).
4546
Type(" bar").
4647
Cancel()
4748

@@ -51,11 +52,11 @@ var CommitWipWithPrefix = NewIntegrationTest(NewIntegrationTestArgs{
5152

5253
t.ExpectPopup().CommitMessagePanel().
5354
Title(Equals("Commit summary")).
54-
InitialText(Equals("foo bar")).
55+
InitialText(Equals("WIP foo bar")).
5556
Type(". Added something else").
5657
Confirm()
5758

5859
t.Views().Commits().Focus()
59-
t.Views().Main().Content(Contains("foo bar. Added something else"))
60+
t.Views().Main().Content(Contains("WIP foo bar. Added something else"))
6061
},
6162
})

0 commit comments

Comments
 (0)