我创建了一个运行linter的pre-commit钩子。pre-commit文件存在于<project>\.githooks\pre-commit.sh中。现在,我想通过make文件与团队成员共享这个钩子。
所以在makefile我做了
.PHONY: all githooks
githooks:
root="$(pwd)"
ln -s "$root/.githooks" "$root/.git/hooks"我搞错了
$ make githooks
root=""
ln -s "oot/.githooks" "oot/.git/hooks"
ln: oot/.git/hooks: No such file or directory
make: *** [githooks] Error 1看起来,我没有将$pwd读入变量,也无法连接2个字符串。我如何在makefile中做到这一点?
更新:
我把钩子换成了
githooks:
root="$$(pwd)"; \
ln -s "$$root/.githooks" "$$root/.git/hooks"这是make文件的输出
[ 1:31PM ] [ ~ ]
$ make githooks
root="$(pwd)"; \
ln -s "$root/.githooks" "$root/.git/hooks"
[ 1:32PM ] [ ~ ]
$ find . -maxdepth 1 -type l -lsfind命令没有返回任何链接。我试过git commit,但是钩子没有得到triger。
发布于 2019-10-07 17:29:02
有两个问题。
root在第一个shell中定义,但在执行ln的shell中没有定义。在执行行之前,整个脚本需要在recipe.$(pwd)中的一个逻辑行上展开一个名为pwd的Makefile变量。若要保留命令替换,请将$:$$(pwd)加倍。同样,$$root也需要传递$root以使shell展开。现在,oot.正在尝试展开Makefile变量r,这个变量也没有定义,后面跟着文字文本r
正确的食谱是
githooks:
root="$$(pwd)"; \
ln -s "$$root/.githooks" "$$root/.git/hooks"https://stackoverflow.com/questions/58274376
复制相似问题