Skip to content

Instantly share code, notes, and snippets.

@theherk
Created November 25, 2021 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theherk/712e9b3d0bb3ff1c33658de2cc45ae01 to your computer and use it in GitHub Desktop.
Save theherk/712e9b3d0bb3ff1c33658de2cc45ae01 to your computer and use it in GitHub Desktop.
Install the latest version of pre-commit locally with GNU Make.
help: ## show help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z./_-]+:.*?##/ { printf " \033[36m%-16s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
bin:
mkdir -p $@
bin/pre-commit: LATEST := ${shell curl --silent "https://api.github.com/repos/pre-commit/pre-commit/releases/latest" | jq ".. .tag_name? // empty" | tr -d '"v'}
bin/pre-commit: URL := https://github.com/pre-commit/pre-commit/releases/download/v${LATEST}/pre-commit-${LATEST}.pyz
bin/pre-commit: bin ## install pre-commit
curl -L ${URL} --output $@
chmod +x $@
@echo 'export PATH=${@D}:$$PATH # remember to add to your PATH'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment