Skip to content

feat(ui): add lightweight color formatting to commit types#52

Open
Nithin0306 wants to merge 1 commit into
nirvik34:mainfrom
Nithin0306:feat/colored-commit-types
Open

feat(ui): add lightweight color formatting to commit types#52
Nithin0306 wants to merge 1 commit into
nirvik34:mainfrom
Nithin0306:feat/colored-commit-types

Conversation

@Nithin0306
Copy link
Copy Markdown

@Nithin0306 Nithin0306 commented May 28, 2026

Description

Fixes #2

Added lightweight color formatting to the Gitbun CLI to improve readability and make different commit types easier to scan quickly in the terminal.

  • Added commitColors.ts utility which maps conventional commit types (e.g., feat, fix, docs, refactor) to Chalk colors.
  • Integrated the color formatting into the interactive preview prompt and the --dry-run output.
  • Ensured the raw commit string passed to Git remains completely untouched so ANSI color codes do not bleed into the Git history.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Documentation update
  • Frontend styling/component update

GSSoC '26 Contribution Details

Please select only one difficulty level that was assigned to you in the issue:

  • level:intermediate

  • level:advanced

  • level:critical

  • level:beginner

  • I have been assigned to this issue by a maintainer. (PRs without prior assignment will not count toward GSSoC).

How Has This Been Tested?

  • npm test passes locally
  • npm run lint passes without errors
  • I ran the CLI locally using npm run dev and verified the output

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas

Summary by CodeRabbit

  • New Features
    • Commit messages now display with color-coded formatting based on conventional commit types in both dry-run previews and interactive confirmation prompts. Distinct colors are assigned to each commit type, making messages more visually organized, easier to distinguish, and more readable. This enhancement improves the overall user experience when reviewing commits.

Review Change Stack

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

@Nithin0306 is attempting to deploy a commit to the nirvik34's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 28, 2026

Warning

.coderabbit.yaml has a parsing error

The CodeRabbit configuration file in this repository has a parsing error and default settings were used instead. Please fix the error(s) in the configuration file. You can initialize chat with CodeRabbit to get help with the configuration file.

💥 Parsing errors (1)
Validation error: Invalid option: expected one of "chill"|"assertive" at "reviews.profile"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 13ef11b0-02f6-41fc-a3c5-bb8da5727f3d

📥 Commits

Reviewing files that changed from the base of the PR and between cc91567 and 5800ce8.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • src/index.ts
  • src/ui/interactive.ts
  • src/utils/commitColors.ts

📝 Walkthrough

Walkthrough

A new utility module adds a conventional-commit type to Chalk color mapping and exports colorizeCommitMessage() to colorize the type prefix of commit messages. This utility is integrated into the dryRun output and confirmCommit interactive prompt to display colored commits instead of plain text.

Changes

Colored Commit Types

Layer / File(s) Summary
Commit message colorization utility
src/utils/commitColors.ts
A new module defines a commitTypeTheme lookup mapping conventional commit types (feat, fix, docs, chore, refactor, etc.) to Chalk color functions. The exported colorizeCommitMessage(message) function regex-matches the commit type prefix (with optional scope and !), returns the input unchanged if no match or unknown type, and otherwise applies the themed Chalk color to only the matched prefix while preserving the remainder of the original message.
Integration into UI output flows
src/index.ts, src/ui/interactive.ts
The colorizeCommitMessage() utility is imported and used in two locations: the dryRun flow in index.ts now wraps commitMessage with colorization before output, and confirmCommit() in interactive.ts now logs the colorized version of the message during the user confirmation prompt. Both changes preserve the control flow and return values of their respective functions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Colors bloom in the terminal,
Commit types now leap and shine,
Green for features, red for fixes bright,
Each message a work of art divine,
Gitbun's canvas grows more fine! 🎨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding lightweight color formatting to commit types, which is the primary objective of this PR.
Linked Issues check ✅ Passed The PR fully addresses issue #2 by implementing lightweight color formatting for conventional commit types using Chalk, integrating it into interactive output while preserving raw commit text for Git.
Out of Scope Changes check ✅ Passed All changes are focused and in-scope: three files modified to add color formatting utility and integrate it into existing UI flows, with no unrelated modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Colored Commit Types

1 participant