Skip to content

No colors when hooks are run by a git commit #1381

Closed

Description

@Cielquan

Hi,
I use pre-commit at home on linux which works perfect. But at work I have a windows pc. Here I have problems with the colorfull output.

When the hooks are run by tox calling pre-commit run there are colors as usual. When the hooks are run by a git commit the colors are missing.

Concrete I mean the green for 'Passed', red for 'Failed ' and yellow/brown for 'Skipped' in the overview.

There is no difference if I run it via git-bash, cmd or powershell. Also there is no difference if I use the pycharm buildin terminal or others.

Activity

  1. asottile commented on Apr 2, 2020

    @asottile
    Member

    colors on windows are a bit fiddly and unfortunately there isn't much we can do to change them when run from git -- we try and call SetConsoleMode here but if that fails you don't get colors

  2. Cielquan commented on Apr 2, 2020

    @Cielquan
    Author

    Ok thanks for the fast answer.
    Then I have to live with it :(

  3. asottile commented on Apr 2, 2020

    @asottile
    Member

    actually hmm, on windows sys.stdout.isatty() is false, but sys.stderr.isatty() is true -- which is different than linux, maybe if we use stderr instead of stdout?

  4. Cielquan commented on Apr 2, 2020

    @Cielquan
    Author

    When I run sys.std---.isatty() on my windows maschine both are false when run from pycharm python console. But both are true when run from the terminal regardless if via invoking a python console first or by running python -c.

  5. asottile commented on Apr 2, 2020

    @asottile
    Member

    can you try the patch in #1382?

  6. Cielquan commented on Apr 2, 2020

    @Cielquan
    Author

    Sure let me try .. may take a bit.

  7. Cielquan commented on Apr 2, 2020

    @Cielquan
    Author

    It does work 👍

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions