gpt4 book ai didi

Git 预提交 Hook 无法运行 gradle 命令

转载 作者:行者123 更新时间:2023-12-03 05:33:23 27 4
gpt4 key购买 nike

我正在尝试运行以下 git pre-commit 钩子(Hook):

#!/bin/bash

echo "Running git pre-commit hook"

# Format code using KtLint
./gradlew app:ktlintFormat app:ktlint --daemon --stacktrace

RESULT=$?

if [ "$RESULT" = 0 ] ; then
echo "Ktlint found no problems."
exit 0
else
echo 1>&2 "Ktlint found violations it could not fix."
exit 1
fi

但它一直在失败。
问题似乎是我的应用程序 build.gradle 文件,我在其中使用了 gladed/gradle-android-git-version gradle script应用版本名称和代码。

这是堆栈跟踪
Commit failed with error
0 files committed, 3 files failed to commit: Simplified examination dialog layout and usage.

Running git pre-commit hook
Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/TBS/StudioProjects/SmartGFR/app/build.gradle' line: 37

* What went wrong:
A problem occurred evaluating project ':app'.
> Bare Repository has neither a working tree, nor an index

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating project ':app'.

异常指向我的应用程序 build.gradle 文件中的以下行:
android {
...
defaultConfig {
...
versionName androidGitVersion.name()
...
}

有人知道怎么修这个东西吗?

最佳答案

我在本地修复了这个@bohsen。
步骤:

  • 进行修改 [https://github.com/gladed/gradle-android-git-version/issues/87#issue-731476471]
  • 生成本地jar
  • 导入jar并应用插件
  • 重新运行钩子(Hook)

  • 问题:
    https://github.com/gladed/gradle-android-git-version/issues/87

    关于Git 预提交 Hook 无法运行 gradle 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58023225/

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