Skip to content

Commit 3182fd3

Browse files
committed
fix: workflow release
1 parent baadc8c commit 3182fd3

3 files changed

Lines changed: 47 additions & 42 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
version: latest
3232
args: release --clean --skip-sign
3333
env:
34-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
3535

3636
docker:
3737
runs-on: ubuntu-latest

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ func generateCommitMessage(mode string) cli.ActionFunc {
162162

163163
fmt.Print("Do you want to use this commit message? [y/N] ")
164164
var response string
165-
fmt.Scanln(&response)
165+
_, err = fmt.Scanln(&response)
166+
if err != nil {
167+
// Handle scan error (e.g., EOF)
168+
response = ""
169+
}
166170

167171
if strings.ToLower(response) == "y" || strings.ToLower(response) == "yes" {
168172
if err := executeCommit(mode, commitMessage); err != nil {
@@ -215,7 +219,7 @@ func analyzeStagedChanges() (string, error) {
215219
}
216220
if _, err := os.Stat(file); err == nil {
217221
analysisInput.WriteString(fmt.Sprintf("\n--- %s ---\n", file))
218-
cmd = exec.Command("git", "diff", "--cached", "--unified=3", file)
222+
cmd = exec.Command("git", "diff", "--cached", "--unified=3", "--", file)
219223
output, _ := cmd.Output()
220224
if len(output) > 2000 {
221225
output = output[:2000]

utils_test.go

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,42 @@ func TestCleanCommitMessage(t *testing.T) {
6868
}
6969
}
7070

71+
// resolveProviderCommand returns the command for a given provider and whether it's a Claude provider.
72+
func resolveProviderCommand(provider string) (string, bool) {
73+
switch {
74+
case strings.HasPrefix(provider, "claude"):
75+
return "claude", true
76+
case provider == "gemini":
77+
return "gemini", false
78+
case provider == "copilot":
79+
return "copilot", false
80+
default:
81+
return "", false
82+
}
83+
}
84+
85+
// validateProviderMapping validates that a provider maps to the expected command.
86+
func validateProviderMapping(t *testing.T, provider, expectedCmd string, actualCmd string, isClaude bool) {
87+
switch {
88+
case strings.HasPrefix(provider, "claude"):
89+
if !isClaude {
90+
t.Errorf("Provider %s should be recognized as claude provider", provider)
91+
}
92+
if actualCmd != "claude" {
93+
t.Errorf("Provider %s should map to 'claude' command, got %s", provider, actualCmd)
94+
}
95+
case provider == "gemini" || provider == "copilot":
96+
if provider != expectedCmd {
97+
t.Errorf("Provider %s should map to '%s' command, got %s", provider, expectedCmd, actualCmd)
98+
}
99+
default:
100+
// Unsupported providers
101+
if isClaude || actualCmd != "" {
102+
t.Errorf("Provider %s should be unsupported", provider)
103+
}
104+
}
105+
}
106+
71107
func TestProviderValidation(t *testing.T) {
72108
tests := []struct {
73109
provider string
@@ -98,43 +134,8 @@ func TestProviderValidation(t *testing.T) {
98134

99135
for _, tt := range tests {
100136
t.Run(tt.provider, func(t *testing.T) {
101-
// Test provider validation logic
102-
var isClaudeProvider bool
103-
var command string
104-
105-
switch {
106-
case strings.HasPrefix(tt.provider, "claude"):
107-
isClaudeProvider = true
108-
command = "claude"
109-
case tt.provider == "gemini":
110-
isClaudeProvider = false
111-
command = "gemini"
112-
case tt.provider == "copilot":
113-
isClaudeProvider = false
114-
command = "copilot"
115-
default:
116-
isClaudeProvider = false
117-
command = ""
118-
}
119-
120-
// For claude-prefixed providers, we expect them to be supported
121-
if strings.HasPrefix(tt.provider, "claude") {
122-
if !isClaudeProvider {
123-
t.Errorf("Provider %s should be recognized as claude provider", tt.provider)
124-
}
125-
if command != "claude" {
126-
t.Errorf("Provider %s should map to 'claude' command, got %s", tt.provider, command)
127-
}
128-
} else if tt.provider == "gemini" || tt.provider == "copilot" {
129-
if tt.provider != "gemini" && tt.provider != "copilot" {
130-
t.Errorf("Provider %s should be handled separately", tt.provider)
131-
}
132-
} else {
133-
// Unsupported providers
134-
if isClaudeProvider || command != "" {
135-
t.Errorf("Provider %s should be unsupported", tt.provider)
136-
}
137-
}
137+
command, isClaude := resolveProviderCommand(tt.provider)
138+
validateProviderMapping(t, tt.provider, tt.expectedCmd, command, isClaude)
138139

139140
// Validate expected behavior
140141
if tt.isSupported && command == "" && !strings.HasPrefix(tt.provider, "claude") {
@@ -271,7 +272,7 @@ func TestGitRepositoryDetection(t *testing.T) {
271272
var _ bool = isGitRepo()
272273
}
273274

274-
// Edge case tests
275+
// Edge case tests.
275276
func TestEdgeCases(t *testing.T) {
276277
t.Run("empty analysis input", func(t *testing.T) {
277278
// Test that empty analysis input is handled
@@ -309,7 +310,7 @@ Git diff analysis:
309310
})
310311
}
311312

312-
// Performance tests
313+
// Performance tests.
313314
func BenchmarkCleanCommitMessageSimple(b *testing.B) {
314315
message := "feat: add new feature"
315316
for i := 0; i < b.N; i++ {

0 commit comments

Comments
 (0)