From 90c8a5d4382e711a7eb0d62e67269d27c77ac08f Mon Sep 17 00:00:00 2001 From: yujeong-jeon Date: Fri, 4 Jul 2025 14:23:12 +0900 Subject: [PATCH 1/2] Modify main.go to handle unchanged commit messages without modification --- packages/commithelper-go/main.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/commithelper-go/main.go b/packages/commithelper-go/main.go index eb40236..1afd010 100644 --- a/packages/commithelper-go/main.go +++ b/packages/commithelper-go/main.go @@ -36,6 +36,23 @@ func main() { commitMessage = input } + // Check if commit message is already tagged + if isAlreadyTagged(commitMessage) { + // Do not modify if already tagged + if _, err := os.Stat(input); err == nil { + // Write back unchanged if input was a file + err = ioutil.WriteFile(input, []byte(commitMessage), 0644) + if err != nil { + fmt.Printf("Error writing to commit message file: %v\n", err) + os.Exit(1) + } + } else { + // Print unchanged if input was a direct message + fmt.Println(commitMessage) + } + return + } + branchName := getCurrentBranchName() config := loadConfig() @@ -122,3 +139,13 @@ func generatePrefix(branchName string, config Config) string { return fmt.Sprintf("%s#%s", *repo, issueNumber) } + +func isAlreadyTagged(commitMessage string) bool { + // Check if commit message already contains issue tag like [#123] or [org/repo#123] + // This pattern matches: + // - [#123] (simple issue number) + // - [Some-Org/Some_Repo#123] (complex repo with special chars) + pattern := regexp.MustCompile(`^\[.*?#\d+\]`) + trimmedMessage := strings.TrimSpace(commitMessage) + return pattern.MatchString(trimmedMessage) +} From 79128542323491eb9147a7811036f1493373b94f Mon Sep 17 00:00:00 2001 From: yujeong-jeon <148525642+yujeong-jeon@users.noreply.github.com> Date: Fri, 4 Jul 2025 14:24:42 +0900 Subject: [PATCH 2/2] Create public-bikes-swim.md --- .changeset/public-bikes-swim.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changeset/public-bikes-swim.md diff --git a/.changeset/public-bikes-swim.md b/.changeset/public-bikes-swim.md new file mode 100644 index 0000000..43a4dfa --- /dev/null +++ b/.changeset/public-bikes-swim.md @@ -0,0 +1,7 @@ +--- +"@naverpay/commithelper-go": patch +--- + +Modify main.go to handle unchanged commit messages without modification + +PR: [Modify main.go to handle unchanged commit messages without modification](https://github.com/NaverPayDev/cli/pull/43)