Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let the user know if there have been changes to the make-files repo. #87

Open
jmalloc opened this issue Jul 24, 2022 · 1 comment
Open

Comments

@jmalloc
Copy link
Contributor

jmalloc commented Jul 24, 2022

As it stands there's no notification that the cached makefiles in a project are out of date.

I don't think it's worth making this too fancy, just do a HEAD of the download URL and compare the ETag, something like that.

Perhaps on make precommit would be best?

@Evildethow
Copy link

Evildethow commented Oct 7, 2022

@jmalloc @ezzatron

The following makes the client self updating:

CORE_VERSION_FILE := $(MF_PROJECT_ROOT)/artifacts/core-version.txt
REMOTE_CORE_VERSION := $(shell curl -Is https://makefiles.dev/v1 | grep etag | cut -d ':' -f2 | xargs)
LOCAL_CORE_VERSION := $(shell cat "${CORE_VERSION_FILE}" 2>/dev/null)
UPDATE_FILE := artifacts/update.touch

# precommit --- Perform tasks that need to be executed before committing.
.PHONY: precommit
precommit:: update

# update --- Checks for updates and applies if required.
.PHONY: update
update: update-core $(UPDATE_FILE)

# update-core --- Checks if core needs updating.
.PHONY: update-core
update-core:
ifneq ($(REMOTE_CORE_VERSION),$(LOCAL_CORE_VERSION))
	@echo "Remote core version: '$(REMOTE_CORE_VERSION)'"
	@echo "Local core version: '$(LOCAL_CORE_VERSION)'"
	@echo "Core update required"
	@rm -f $(UPDATE_FILE)
endif

$(UPDATE_FILE):
	@rm -rf $(MF_ROOT) artifacts
	@mkdir -p "$(@D)"
	@echo "$(REMOTE_CORE_VERSION)" > $(CORE_VERSION_FILE)
	@touch "$@"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants