使所有克隆git repo。我想知道提交哈希是什么,并将git commit hash分配给一个变量,该变量稍后可以在Makefile中使用
e.g。
all: download
echo '$(GIT_COMMIT)'
download:
cd buildarea && git clone git@github.com:proj/project.git
$(eval GIT_COMMIT = $(shell cd buildarea/project && git log -l --pretty=format:"%H"))
echo '$(GIT_COMMIT)'
答案 0 :(得分:2)
如何使用shell函数和2个目标呢?
all: download getver
getver: VER=$(shell cd buildarea/project && git log -1 --pretty=format:"%H")
getver:
@echo GIT_COMMIT=$(VER)
download:
mkdir -p buildarea && cd buildarea && git@github.com:proj/project.git
答案 1 :(得分:0)
我不确定原因,但似乎git clone
$(shell)
无法cd
进入目录。你可以做的只是在一次$(shell)
电话中执行整个行为。
all: download
echo '$(GIT_COMMIT)'
download:
$(eval GIT_COMMIT = $(shell git clone git@github.com:proj/project.git buildarea/project && cd buildarea/project && git rev-parse HEAD))
echo '$(GIT_COMMIT)'