Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased] - ReleaseDate

### Changed

- (#512) Fixed so that the setting for `--color` is now respected.
- (#512) Fixed so that you can pass `--color` anywhere in the command-line, not just before the subcommand.

## [0.4.0] - 2022-08-09

### Added
Expand Down
7 changes: 7 additions & 0 deletions git-branchless-lib/src/core/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ fn render_style_as_ansi(content: &str, style: Style) -> eyre::Result<String> {
output
};

// `StyledObject` will try to do its own detection of whether or not it
// should render ANSI escape codes. Disable that detection and use whatever
// we've determined, so that the user can force color on or off. (The caller
// will only call this function if the user wants color, so we pass `true`.)
// See https://github.com/arxanas/git-branchless/issues/506
let output = output.force_styling(true);

Ok(output.to_string())
}

Expand Down
4 changes: 2 additions & 2 deletions git-branchless/src/opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,11 +515,11 @@ pub enum ColorSetting {
pub struct Opts {
/// Change to the given directory before executing the rest of the program.
/// (The option is called `-C` for symmetry with Git.)
#[clap(value_parser, short = 'C')]
#[clap(value_parser, short = 'C', global = true)]
pub working_directory: Option<PathBuf>,

/// Flag to force enable or disable terminal colors.
#[clap(value_parser, long = "color", arg_enum)]
#[clap(value_parser, long = "color", arg_enum, global = true)]
pub color: Option<ColorSetting>,

/// The `git-branchless` subcommand to run.
Expand Down