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

Wall-of-text issue with refreshing git hooks #1446

Closed
sQVe opened this issue Jan 26, 2020 · 6 comments
Closed

Wall-of-text issue with refreshing git hooks #1446

sQVe opened this issue Jan 26, 2020 · 6 comments

Comments

@sQVe
Copy link

sQVe commented Jan 26, 2020

Hey 👋,

I'm using https://github.com/typicode/husky for some of my projects and when triggering a hook fugitive outputs a lot of text. I have to press <Space> to go down a full screen more than a couple of times. The text is also blank until I scroll up and down a bit. The following is an example of the output generated:

husky > pre-commit (node v10.18.1)
^[[?25l  ^[[32m✔^[[39m Preparing...
  ^[[33m❯^[[39m Running tasks...
    ^[[33m❯^[[39m Running tasks for *.{js,jsx,ts,tsx}
      ^[[33m⠙^[[39m prettier --write
        eslint --fix
        jest --findRelatedTests
    ^[[33m↓^[[39m Running tasks for *.json ^[[2m[skipped]^[[22m
    ^[[90m  → No staged files match *.json^[[39m
    Applying modifications...
    Cleaning up...

The above text is repeated atleast a 50-100 times (except the first one of course).

Is is possible for fugitive to handle these cases where the git hook is refreshing the output? Or is it possible to fugitive to skip the output?

@sQVe sQVe changed the title Wall-of-text issue with rerendering git hooks Wall-of-text issue with refreshing git hooks Jan 26, 2020
@tpope
Copy link
Owner

tpope commented Jan 26, 2020

Can you try with let g:fugitive_pty = 0?

@sQVe
Copy link
Author

sQVe commented Jan 26, 2020

@tpope Cheers for the quick response. That works way better for me. 👍

Is there a location for all the options for fugitive?

@tpope
Copy link
Owner

tpope commented Jan 26, 2020

That option is primarily intended for debugging. I'd rather users didn't have to be aware of it at all.

The real fix is for Husky to disable those escape sequences when $TERM is dumb, just like it does when stdout isn't a tty. Except it's probably not Husky itself, but something Husky is calling. Any idea what is printing out text like "Running tasks for"? HUSKY_DEBUG=1 might help.

@sQVe
Copy link
Author

sQVe commented Jan 27, 2020

@tpope True oh-so true. I think the culprit here is lint-staged which is run by husky in this case. This is what it looks like in my terminal:

Peek 2020-01-27 08-23

Setting husky to run lint-staged --quiet solves the issue but also, obviously, excludes the progress information. Do you have any pointers on what lint-staged need to handle so I can create an issue with some relevant information.

Closing this issue as it is not an issue with fugitive.

@sQVe sQVe closed this as completed Jan 27, 2020
@tpope
Copy link
Owner

tpope commented Jan 27, 2020

Setting husky to run lint-staged --quiet solves the issue but also, obviously, excludes the progress information.

As a workaround, you can set it to run lint-staged | cat. This should have the same effect as let g:fugitive_pty = 0 without throwing out the baby with the bathwater. (Using a pty enables some small niceties such as progress bars on :Git pull and :Git checkout.)

Do you have any pointers on what lint-staged need to handle so I can create an issue with some relevant information.

Disabling the advanced terminal behavior when TERM is dumb should do the trick. Here's something similar I found when poking around Husky:

https://github.com/chalk/supports-color/blob/8a40054cdbcd3f42b4f68eaefb41c3064835b991/index.js#L65-L67

I also sent a similar patch to a Ruby library: rails/thor#710. I'm now rethinking my decision to check for nil because I worry that might exclude Windows. Checking for dumb only is a safe bet.

Closing this issue as it is not an issue with fugitive.

Technically true, but I'm afraid this will be a popular problem with Git hooks.

@sQVe
Copy link
Author

sQVe commented Jan 27, 2020

Cheers for the input @tpope. I'm creating an issue at lint-staged.

namjul pushed a commit to namjul/gumption-ui that referenced this issue Feb 18, 2021
To not have weird charactors in vim using fugitive i needed to find the
options to disable them.

- For lint-staged i had to set the following env vars
  * FORCE_COLOR=0
    + a flag from https://github.com/chalk/supports-color#readme
  * TERM=dumb
    + this has an effect since https://github.com/okonet/lint-staged/pull/782/files
    + this should be set my vim-fugitive but for some reason i have to set
      it up manually tpope/vim-fugitive#1446
- For commitlint the flag `--color=false` was sufficient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants