Skip to content

feat: Add option to truncate git branch names#383

Merged
ethancedwards8 merged 1 commit intodracula:masterfrom
chmouel:fix-truncat-branch-length
Apr 6, 2026
Merged

feat: Add option to truncate git branch names#383
ethancedwards8 merged 1 commit intodracula:masterfrom
chmouel:fix-truncat-branch-length

Conversation

@chmouel
Copy link
Copy Markdown
Contributor

@chmouel chmouel commented Feb 4, 2026

Added a new option @dracula-git-truncate-length to limit the maximum length of git branch names displayed in the status bar. This let truncate long branch names and not take the full length of the tmux window.

Added a new configuration option `@dracula-git-truncate-length` that
allows users to limit the maximum length of git branch names displayed
in the status bar. This let truncate long branch names and not take the
full length of the tmux window.

Signed-off-by: Chmouel Boudjnah <chmouel@chmouel.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 4, 2026

📝 Walkthrough

Walkthrough

This PR adds a new configuration option @dracula-git-truncate-length to control optional truncation of git branch names in the status bar. The documentation is updated and the git script is modified to read and apply this truncation setting.

Changes

Cohort / File(s) Summary
Documentation
docs/CONFIG.md
Introduces new configuration option @dracula-git-truncate-length with description and usage example.
Git Script Implementation
scripts/git.sh
Retrieves the git truncate length configuration value and applies branch name truncation in getMessage when the option is set.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding an option to truncate git branch names, which is clearly reflected in the code changes.
Description check ✅ Passed The description is directly related to the changeset, explaining the new configuration option and its purpose for truncating long branch names.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist.


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@scripts/git.sh`:
- Around line 145-148: The branch truncation uses git_truncate_length without
validating it, so invalid values like 0, non-numeric, or negative cause
empty/incorrect slicing; update the logic around getBranch/branch handling to
validate git_truncate_length is a positive integer (e.g., regex '^[1-9][0-9]*$'
or an arithmetic check) before applying
branch="${branch:0:$git_truncate_length}", and if validation fails simply skip
truncation so branch remains intact (reference the checkForGitDir block and
variables branch, git_truncate_length, and repo_name to find and fix the code).

Copy link
Copy Markdown
Member

@ethancedwards8 ethancedwards8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how long are your branches? lol

@ethancedwards8 ethancedwards8 merged commit e777b01 into dracula:master Apr 6, 2026
2 checks passed
@chmouel
Copy link
Copy Markdown
Contributor Author

chmouel commented Apr 7, 2026

@ethancedwards8 hah they are auto generated from the description of a pr/issue/jr so pretty long sometime 🙃

@chmouel chmouel deleted the fix-truncat-branch-length branch April 7, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants