Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions core/commit_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ func (m *commitMessage) newTemplate() (*template.Template, error) {
}

func (m *commitMessage) Build() (string, error) {
location, err := getLocation()
if err != nil {
return "", err
}
m.Location = location

tmpl, err := m.newTemplate()
if err != nil {
return "", err
Expand Down
5 changes: 1 addition & 4 deletions core/commit_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,9 @@ func TestCommitMessage(t *testing.T) {
defer setEnvTemporarily("GIT_EXEC_PROMPT", ptn.prompt)()
defer setEnvTemporarily("GIT_EXEC_TEMPLATE", ptn.template)()

var bkGetLocation func() (string, error)
getLocation, bkGetLocation = func() (string, error) { return ptn.location, nil }, getLocation
defer func() { getLocation = bkGetLocation }()

command := &command.Command{Envs: ptn.envs, Args: ptn.args, Output: ptn.output}
commitMsg := newCommitMessage(command, newOptions())
commitMsg.Location = ptn.location

actual, err := commitMsg.Build()
assert.NoError(t, err)
Expand Down
7 changes: 7 additions & 0 deletions core/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ func Run(options *Options, commandArgs []string) error {
return fmt.Errorf("Command execution failed: %+v\n%s", err, cmd.Output)
}
commitMessage = newCommitMessage(cmd, options)

location, err := getLocation()
if err != nil {
return err
}
commitMessage.Location = location

return nil
}); err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion tests/scenes/02_subdir/directory_option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestDirectoryOption(t *testing.T) {
require.NoError(t, err)

commitMessage := stdout(t, "git", "log", "-1", "--pretty=%B")
assert.Equal(t, `🤖 [02_subdir] $ make add-one parent-add-two
assert.Equal(t, `🤖 [02_subdir/sub1] $ make add-one parent-add-two

`, commitMessage)
}
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import "fmt"

const Version = "0.1.2"
const Version = "0.1.3"

func showVersion() {
fmt.Println(Version)
Expand Down
Loading