keyfork/Makefile

25 lines
1.0 KiB
Makefile
Raw Normal View History

BASE_REF ?= main
HEAD_REF ?= $(shell git rev-parse HEAD)
.PHONY: review
review:
@echo "Ensuring Cargo.lock is in clean state, not modified"
test -z "$(shell git status --porcelain | grep -E 'M +Cargo.lock')"
@echo "Ensuring current HEAD_REF is not BASE_REF"
test "$(shell git rev-parse $(BASE_REF))" != "$(HEAD_REF)"
@echo "Verifying if any changes happened in Cargo.lock that require review"
test "$(shell git show $(BASE_REF):Cargo.lock | sha256sum)" != "$(shell git show $(HEAD_REF):Cargo.lock | sha256sum)"
$(eval TEMP_REPO := $(shell mktemp -d))
git -C $(TEMP_REPO) init
# Fetch files for BASE_REF
git show $(BASE_REF):Cargo.lock > $(TEMP_REPO)/Cargo.lock
CARGO_HOME=$(TEMP_REPO)/cargo-home cargo fetch
git -C $(TEMP_REPO) add .
git -C $(TEMP_REPO) commit --no-gpg-sign -m "base ref: $(BASE_REF)"
# Fetch files for HEAD_REF
git show $(HEAD_REF):Cargo.lock > $(TEMP_REPO)/Cargo.lock
CARGO_HOME=$(TEMP_REPO)/cargo-home cargo fetch
git -C $(TEMP_REPO) add -A .
git -C $(TEMP_REPO) difftool HEAD || true
rm -rf $(TEMP_REPO)