Skip to content

Commit

Permalink
add commit hash and author hash
Browse files Browse the repository at this point in the history
  • Loading branch information
jr1221 committed Dec 13, 2024
1 parent 5fd5009 commit fcf9c85
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,25 @@ GIT_MINOR_VERSION := $(shell git describe --tags --abbrev=0 | cut -c2- | cut -d'
GIT_PATCH_VERSION := $(shell git describe --tags --abbrev=0 | cut -c2- | cut -d'.' -f3)
GIT_IS_UPSTREAM_CLEAN := $(shell bash -c 'git merge-base --is-ancestor HEAD @{u} && echo 0 || echo 1')
GIT_IS_LOCAL_CLEAN := $(shell bash -c 'test -z "$$(git status --porcelain)" && echo 0 || echo 1')

GIT_SHORTHASH := $(shell git rev-parse --short=8 HEAD)
GIT_AUTHORHASH := $(shell bash -c 'git log -n 1 --format=%h --author=$(git config --get user.name)')


all:
@echo "Version: $(GIT_MAJOR_VERSION).$(GIT_MINOR_VERSION).$(GIT_PATCH_VERSION)"
@echo "VERSION: $(GIT_MAJOR_VERSION).$(GIT_MINOR_VERSION).$(GIT_PATCH_VERSION)"
@echo "UNPUSHED CHANGES: $(GIT_IS_UPSTREAM_CLEAN)"
@echo "UNCOMMITTED CHANGES: $(GIT_IS_LOCAL_CLEAN)"
@echo "COMMIT HASH: $(GIT_SHORTHASH)"
@echo "AUTHOR HASH: $(GIT_AUTHORHASH)"

CFLAGS += -DGIT_MAJOR_VERSION=$(GIT_MAJOR_VERSION) \
-DGIT_MINOR_VERSION=$(GIT_MINOR_VERSION) \
-DGIT_PATCH_VERSION=$(GIT_PATCH_VERSION) \
-DGIT_IS_UPSTREAM_CLEAN=$(GIT_IS_UPSTREAM_CLEAN) \
-DGIT_IS_LOCAL_CLEAN=$(GIT_IS_LOCAL_CLEAN)
-DGIT_IS_LOCAL_CLEAN=$(GIT_IS_LOCAL_CLEAN) \
-DGIT_SHORTHASH=$(GIT_SHORTHASH) \
-DGIT_AUTHORHASH=$(GIT_AUTHORHASH)

######################################
# building variables
######################################
Expand Down

0 comments on commit fcf9c85

Please sign in to comment.