From b5d69ff0104eb7d9f7ab956be894c3bfd49e37ec Mon Sep 17 00:00:00 2001 From: Wen Kokke Date: Wed, 19 Aug 2020 22:13:39 +0200 Subject: [PATCH] Moved Git hooks to the .githooks directory, and created make init script. --- .githooks/pre-commit | 12 ++++++++++++ Makefile | 5 +++++ README.md | 7 +++++-- 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100755 .githooks/pre-commit diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..0ba8b720 --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,12 @@ +#!/bin/sh +# +# Check if fix-whitespace is installed, and if so, run it. +# + +if ! command -v fix-whitespace &> /dev/null +then + echo "fix-whitespace could not be found" + exit +else + fix-whitespace --check +fi \ No newline at end of file diff --git a/Makefile b/Makefile index 980a555f..b0999641 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,11 @@ SEDI := sed -i endif +# Configure the repository to use .githooks +init: + git config core.hooksPath .githooks + + # Build PLFA web version and test links default: test diff --git a/README.md b/README.md index 4d98d95e..708c1652 100644 --- a/README.md +++ b/README.md @@ -143,15 +143,17 @@ You'll see the key sequence of the character in mini buffer. PLFA is available as both a website and an EPUB e-book, both of which can be built on Linux and macOS. PLFA is written in literate Agda with [Kramdown Markdown][kramdown]. + ### Git hooks -The repository comes with several pre-commit Git hooks installed: +The repository comes with several Git hooks: 1. The [fix-whitespace][fix-whitespace] program is run to check for whitespace violations. 2. The test suite is run to check if everything type checks. -If you don’t have [fix-whitespace][fix-whitespace] installed, you can circumvent the pre-commit Git hooks by passing `--no-verify`. +You can install these Git hooks by calling `make init`. + ### Building the website @@ -198,6 +200,7 @@ bundle install bundle exec jekyll serve ``` + ### Building the EPUB The [EPUB version][epub] of the book is built using Pandoc.