Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling empty values of NO_COLOR and FORCE_COLOR #11712

Merged
merged 2 commits into from
Dec 23, 2023

Commits on Dec 16, 2023

  1. Fix handling empty values of NO_COLOR and FORCE_COLOR

    Fix handling NO_COLOR and FORCE_COLOR environment variables to correctly
    be ignored when they are set to an empty value, as defined
    in the specification:
    
    > Command-line software which adds ANSI color to its output by default
    > should check for a NO_COLOR environment variable that, when present
    > *and not an empty string* (regardless of its value), prevents
    > the addition of ANSI color.
    
    (emphasis mine, https://no-color.org/)
    
    The same is true of FORCE_COLOR, https://force-color.org/.
    mgorny committed Dec 16, 2023
    Configuration menu
    Copy the full SHA
    4a18fc3 View commit details
    Browse the repository at this point in the history

Commits on Dec 17, 2023

  1. Streamline testing for FORCE_COLOR and NO_COLOR

    Streamline the tests for FORCE_COLOR and NO_COLOR variables, and cover
    all possible cases (unset, set to empty, set to "1").  Combine the two
    assert functions into one taking boolean parameters.  Mock file.isatty
    in all circumstances to ensure that the environment variables take
    precedence over the fallback value resulting from isatty check (or that
    the fallback is actually used, in the case of both FORCE_COLOR
    and NO_COLOR being unset).
    mgorny committed Dec 17, 2023
    Configuration menu
    Copy the full SHA
    dbeca32 View commit details
    Browse the repository at this point in the history