In a Makefile, how can I get and assign a hash hash heg hep to a variable?

A do everything clone git repo. I want to know what a hash commit is and assign a git commit hash code that can be used later in the Makefile

eg.

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)' 
+5
source share
2 answers

How about using a shell function and 2 goals for it?

 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
source

I don’t know exactly why, but it seems that after git clone $(shell) cannot cd into the directory. You can simply execute the whole act with a single call to $(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)' 
0
source

Source: https://habr.com/ru/post/1240304/


All Articles