From 33d04f6bf4b3a85c866d5c7fae9bf8ead10de4be Mon Sep 17 00:00:00 2001 From: akm Date: Sun, 8 Dec 2024 18:22:26 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=85=20Fix=20TestDirectoryOption?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/scenes/02_subdir/directory_option_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/scenes/02_subdir/directory_option_test.go b/tests/scenes/02_subdir/directory_option_test.go index 9733af4..b763101 100644 --- a/tests/scenes/02_subdir/directory_option_test.go +++ b/tests/scenes/02_subdir/directory_option_test.go @@ -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) } From dfbbac1e0c2498b19eae585c194362cc26503a1d Mon Sep 17 00:00:00 2001 From: akm Date: Sun, 8 Dec 2024 18:33:24 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=90=9B=20Call=20getLocation=20in=20ch?= =?UTF-8?q?angeDir=20callback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/commit_message.go | 6 ------ core/commit_message_test.go | 5 +---- core/run.go | 7 +++++++ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/core/commit_message.go b/core/commit_message.go index 1622aba..3155910 100644 --- a/core/commit_message.go +++ b/core/commit_message.go @@ -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 diff --git a/core/commit_message_test.go b/core/commit_message_test.go index af90947..0055fa7 100644 --- a/core/commit_message_test.go +++ b/core/commit_message_test.go @@ -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) diff --git a/core/run.go b/core/run.go index 2ea8cb5..dad12e3 100644 --- a/core/run.go +++ b/core/run.go @@ -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 From b79a977186dbcd6ab970aab3dedb342469d83dfe Mon Sep 17 00:00:00 2001 From: akm Date: Sun, 8 Dec 2024 18:34:02 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=8E=89=20Bump=20up=20from=200.1.2=20t?= =?UTF-8?q?o=200.1.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.go b/version.go index f1b6067..3735629 100644 --- a/version.go +++ b/version.go @@ -2,7 +2,7 @@ package main import "fmt" -const Version = "0.1.2" +const Version = "0.1.3" func showVersion() { fmt.Println(Version)