Skip to content

[FEATURE] Add --dry-run flag to preview generated commit message without staging or committing anything #56

@Sweksha-Kakkar

Description

@Sweksha-Kakkar

✨ Enhancement: --dry-run flag for safe message preview

Summary

Gitbun currently has two modes: interactive (shows preview, asks for confirmation) and --auto (commits immediately). There is no way to only see what message would be generated without touching the Git index or creating a commit.

This is a common use case for:

  • Developers testing a custom .gitbunrc config or customPrompt
  • CI pipelines that want to validate commit message quality before committing
  • Contributors checking gitbun's fallback output against their diff without side effects

Proposed Behaviour

A new flag --dry-run (alias: -n) should:

  1. Run the full gitbun pipeline (AI call or fallback, scope/type detection)
  2. Print the generated commit message to stdout
  3. Exit without staging any files or running git commit

Example output:

$ gitbun --dry-run

🔍 Dry run mode — no files will be staged or committed.

Generated commit message:
─────────────────────────────────────
feat(analyzer): add support for multi-file scope detection
─────────────────────────────────────

AI model used : deepseek-coder:6.7b (Ollama)
Confidence    : high
Files analyzed: src/analyzer/scopeDetector.ts, src/analyzer/summarizer.ts

Why This Matters

Currently, the only way to test gitbun's output quality is to actually run it interactively or inspect source code. A --dry-run flag makes gitbun composable in shell scripts and safe to evaluate without risk of accidental commits — especially important in team onboarding or CI validation steps.


Implementation Notes

  • Should work alongside --no-ai to test fallback output: gitbun --dry-run --no-ai
  • Should work with --model to compare model outputs: gitbun --dry-run --model llama3
  • Exit code 0 on success (message generated), 1 on failure (AI error, no staged files)
  • Output should go to stdout so it can be piped: gitbun --dry-run | grep "feat"

Environment

  • All platforms (Node.js 18+)
  • gitbun v1.13.0 (main branch)

Expected Behaviour

After this flag is implemented:

  • gitbun --dry-run prints the generated commit message and exits with code 0 — no git commit is run, no files are staged
  • gitbun --dry-run --no-ai tests the rule-based fallback output specifically
  • gitbun --dry-run --model llama3 uses the specified model for generation without committing
  • The flag is documented in the README usage table alongside existing flags
  • gitbun --help includes --dry-run / -n with description: "Preview generated commit message without committing"

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions