Skip to content

Commit

Permalink
Makefile: Also check git hash for detecting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Jan 5, 2024
1 parent 40e095d commit a3fa09e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ vendor
.vscode/

.diff_*
.git_*

*.log
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,15 @@ build: lint swag ## Build the binary file
echo "Not supported Operating System. ($$kernel_name)"; \
fi
@git diff > .diff_last_build
@git rev-parse HEAD > .git_hash_last_build
@echo Build finished!

run: ## Run the built binary
@git diff > .diff_current
@STATUS=`diff .diff_last_build .diff_current 2>&1 > /dev/null; echo $$?` && \
if [ "$$STATUS" != "0" ]; then \
GIT_HASH_MINE=`git rev-parse HEAD` && \
GIT_HASH_LAST_BUILD=`cat .git_hash_last_build 2>&1 > /dev/null | true` && \
if [ "$$STATUS" != "0" ] || [ "$$GIT_HASH_MINE" != "$$GIT_HASH_LAST_BUILD" ]; then \
$(MAKE) build; \
fi
@cp -RpPf conf cmd/${MODULE_NAME}/ && ./cmd/${MODULE_NAME}/${MODULE_NAME}* || echo "Trying with sudo..." && sudo ./cmd/${MODULE_NAME}/${MODULE_NAME}*
Expand Down

0 comments on commit a3fa09e

Please sign in to comment.