如何将错误从 git-hooks 打印到 Android Studio 事件日志?

How to print errors from git-hooks to Android Studio Event Log?

我有 git-hook:

预提交

#!/bin/bash
java -jar ktlint --color "/\**/src/**/*.kt"
if [[ $? -gt 0 ]]; then
  echo -e "3[0;31mKotlin Code style violation. Please check errors above!3[0m\n"
  echo -e "Hint: use \"./ktlint  -F <file pattern>\" for autocorrection.\n"
  exit 1
fi

当我使用终端命令时:

>git commit -m "Any message"

输出在终端中,对我来说没问题:

但是当我使用 Android Studio -> VCS -> Commit... Ctrl+K 输出在Event Log,看不懂:

找到解决方案:

#!/bin/sh
KOTLIN_LINTER_FILE=ktlint
TEMP_DIRECTORY=.temp
git diff --name-only --cached --relative | grep '.*kt$' | xargs ${TEMP_DIRECTORY}\${KOTLIN_LINTER_FILE} --relative .
if [[ $? -ne 0 ]]; then exit 1; fi