gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 17:58:14 24 4
gpt4 key购买 nike

我有git-hook:

预先提交

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


当我使用终端命令时:

>git commit -m "Any message"

输出在terminal,对我来说还可以:
enter image description here

但是当我使用 Android Studio-> VCS-> Commit... Ctrl + K时
输出在 Event Log中,并且无法理解: enter image description here

最佳答案

找到的解决方案:

#!/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

关于git - 如何将错误从git-hooks打印到Android Studio事件日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55629974/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com