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

Support for interactive git hooks? #82512

Closed
janosh opened this issue Oct 14, 2019 · 1 comment
Assignees

Comments

@janosh
Copy link

@janosh janosh commented Oct 14, 2019

I wrote a global git hook for spell checking commit messages. It displays to the user a list of possible spelling mistakes (if any) and prompts to either abort the commit and modify the message or proceed anyway.

Everything works as expected on the command line. But using VS Code's built-in source control UI, I get the error /dev/tty: Device not configured.

Any way for VS Code to support interactive git hooks?

Global commit-msg hook

#!/bin/sh

if ! command -v aspell &>/dev/null; then
  printf "%s\n" "[commit-msg hook] Warning: 'aspell' not installed. Unable to spell check commit message."
else
  wordList=( $(grep -v "^  " "$1" | aspell list) )
fi

if (( "${#wordList[@]}" > 0 )); then
  printf "%s\n" "[commit-msg hook] Possible spelling errors found in commit message:" "${wordList[@]}"
fi

exec < /dev/tty

while true; do
  read -p "[commit-msg hook] Proceed anyway? (y/n) " yn
  if [ "$yn" = "" ]; then
    yn='y'
  fi
  case $yn in
      [Yy] ) break;;
      [Nn] ) exit 1;;
      * ) echo "Please answer y for yes or n for no.";;
  esac
done
@joaomoreno

This comment has been minimized.

Copy link
Member

@joaomoreno joaomoreno commented Oct 15, 2019

Very likely there won't be any support more than the current API. You can add some way to call back to an extension running in VSCode which would show up some UI for the user to interact with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.