Skip to content

Playbooks for g

Story-style workflows—solo, team, and on-call. Jump into the full Use cases page anytime.

commands::commit

Interactive commit builder and commit execution.

auto-generated This page is built from //! comments in the Rust source. Edit the source and run npm run docs:extract to update it.

Interactive commit builder and commit execution.

g commit has two paths:

  • Guided / interactive — when no --message flag is given, the user is walked through a series of prompts (type, scope, subject, body, footer) to build a Conventional Commit message.
  • Non-interactive — when --message is given the prompts are skipped and the commit is made immediately.

In both cases the commit is executed via [gitcmd::git_output] and the result is displayed with a coloured success/error summary.

Folder layout

commit/
  mod.rs      ← this file: public `commit()` entry point + orchestration
  parse.rs    ← pure helpers (extract_body, parse_conventional_type,
                message_from_flags) with unit tests
  preview.rs  ← display helpers (show_staged_summary, colorize_stat_line,
                type_label_parts)
  dry_run.rs  ← `--dry-run` path: print planned `git commit` invocation
  builder.rs  ← interactive + inline commit-message builders + type picker

Source: src/commands/commit/mod.rs