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
9 changes: 6 additions & 3 deletions cmd/draft.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func processCommitMessage(commitMessage string, noEmoji bool, configTypes []mode
var builder strings.Builder
builder.WriteString(commitType)

hasEmoji := false
if !noEmoji {
var emoji string
for _, t := range configTypes {
Expand All @@ -174,12 +175,12 @@ func processCommitMessage(commitMessage string, noEmoji bool, configTypes []mode
if emoji != "" {
builder.WriteString(" ")
builder.WriteString(emoji)
hasEmoji = true
}
}

if fullScopePart != "" {

if !strings.HasSuffix(builder.String(), " ") {
if hasEmoji {
builder.WriteString(" ")
}
builder.WriteString(fullScopePart)
Expand Down Expand Up @@ -213,7 +214,9 @@ var draftCmd = &cobra.Command{
var provider ai.AIProvider
switch cfg.AIProvider {
case "phind":
printErrorAndExit("❌ Phind provider has been permanently shut down and is no longer supported. Please update your .goji.json to use 'openrouter', 'groq', or 'gemini' instead.")
printErrorAndExit(
"❌ Phind provider has been permanently shut down and is no longer supported. Please update your .goji.json to use 'openrouter', 'groq', or 'gemini' instead.",
)
case "openrouter":
apiKey := os.Getenv("OPENROUTER_API_KEY")
if apiKey == "" {
Expand Down
24 changes: 14 additions & 10 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,11 @@ func constructCommitMessage(cfg *config.Config, typeFlag, scopeFlag, messageFlag

commitHeader := typeMatch
if scopeFlag != "" {
commitHeader += fmt.Sprintf(" (%s)", scopeFlag)
if !cfg.NoEmoji {
commitHeader += fmt.Sprintf(" (%s)", scopeFlag)
} else {
commitHeader += fmt.Sprintf("(%s)", scopeFlag)
}
}

return fmt.Sprintf("%s: %s", commitHeader, messageFlag)
Expand Down Expand Up @@ -178,7 +182,7 @@ func getVersion() string {
if version != "" {
return version
}

// Try to get version from git describe
cmd := exec.Command("git", "describe", "--tags", "--always", "--dirty")
output, err := cmd.Output()
Expand All @@ -188,7 +192,7 @@ func getVersion() string {
v = strings.TrimPrefix(v, "v")
// Clean up any newlines
v = strings.TrimRight(v, "\n\r")
// If the version contains a dash (e.g., "0.1.8-2-g035f84e-dirty"),
// If the version contains a dash (e.g., "0.1.8-2-g035f84e-dirty"),
// extract just the version part before the first dash for cleaner output
if idx := strings.Index(v, "-"); idx > 0 {
// Keep the full string if it's just a commit hash, otherwise use prefix
Expand All @@ -200,7 +204,7 @@ func getVersion() string {
return v
}
}

// Fallback to "dev" if git is not available or not in a git repo
return "dev"
}
Expand All @@ -217,25 +221,25 @@ func showNotInGitRepoMessage(cmd *cobra.Command) error {
color.Set(color.FgYellow)
fmt.Println("\n⚠️ You're not in a git repository.")
color.Unset()

fmt.Println("\nGoji is a CLI tool for generating conventional commit messages with emojis.")
fmt.Println("To use goji, you need to be in a git repository.")

fmt.Println("\n💡 Quick tips:")
fmt.Println(" 1. Initialize a git repository: git init")
fmt.Println(" 2. Initialize goji config: goji init --global")
fmt.Println(" 3. Or initialize repo config: goji init --repo (requires git repo)")

fmt.Println("\n📚 For more information:")
fmt.Println(" • View help: goji --help")
fmt.Println(" • Initialize config: goji init --help")
fmt.Println(" • Read the README: https://github.com/muandane/goji")

fmt.Println()

// Show help output
_ = cmd.Help()

// Return nil (no error) so we exit with code 0
return nil
}
Expand Down
Loading