--color does not control the dry-run diff's colors

Open Beginner friendly
#11 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
cli

Research direction

Read crates/bumpversion-cli/src/common.rs for how --color sets the override, then inspect crates/bumpversion/src/files.rs where similar_asserts::SimpleDiff produces the dry-run diff. Apply the color setting to the console crate as the issue describes and check both --color always and --color never with a piped dry run; done means the diff follows the flag for the whole output.

Written by the indexing model from the issue text.

Description

bug

--color does not control the colors of the dry-run report's diff ("Differences (-before|+after)"). The diff comes from similar_asserts::SimpleDiff in crates/bumpversion/src/files.rs, which colors through the console crate, while --color only sets colored::control::set_override in crates/bumpversion-cli/src/common.rs. So the diff follows console's own detection (a TTY, CLICOLOR_FORCE), not the flag:

$ bumpversion --color always --dry-run -vv patch 2>&1 | cat -v | grep -A1 Differences
^[[34m [DRY-RUN] ^[[0m	Differences (-before|+after):^[[0;0m
^[[34m [DRY-RUN] ^[[0m	-1.0.0^[[0;0m
$ CLICOLOR_FORCE=1 bumpversion --color never --dry-run -vv patch 2>&1 | cat -v | grep -A1 Differences
 [DRY-RUN] 	^[[1mDifferences^[[0m (^[[31m^[[2m-^[[0m^[[31mbefore^[[0m|^[[32m^[[2m+^[[0m^[[32mafter^[[0m):^[[0;0m
 [DRY-RUN] 	^[[31m^[[1m^[[2m-^[[0m^[[31m^[[1m^[[4m1.0.0^[[0m^[[31m^[[0;0m

--color always leaves a piped diff plain, which is why the docs capture script has to set CLICOLOR_FORCE=1, and --color never still colors it.

Expected: --color decides for the whole output. Calling console::set_colors_enabled(use_color) (and set_colors_enabled_stderr) next to colored::control::set_override(use_color) would do it.

Dominant language
Rust
Stars
1
Forks
0
Avg merge
12m
Merged PRs (30d)
1

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from romnn/bumpversion

All issues in romnn/bumpversion

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.