From 052f3e9d9c7928ad32a2e94823174ab082483fb7 Mon Sep 17 00:00:00 2001 From: Andre Richter Date: Sat, 12 Jan 2019 21:52:46 +0100 Subject: [PATCH] Add a pre-commit hook --- .githooks/pre-commit | 20 ++++++++++++++++++++ contributor_setup.sh | 3 +++ 2 files changed, 23 insertions(+) create mode 100755 .githooks/pre-commit create mode 100755 contributor_setup.sh diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..110771bd --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby + +require_relative '../utils/copyrighted' + +source_files_exts = ['.S', '.rs', '.rb'] + +staged_files = `git --no-pager diff --name-only --cached`.split(/\n/) + +need_inspection = [] +staged_files.each do |f| + need_inspection << f if + f == 'Makefile' || source_files_exts.include?(File.extname(f)) +end + +error = false +need_inspection.each do |f| + error = true unless copyrighted?(f, true) +end + +exit 1 if error diff --git a/contributor_setup.sh b/contributor_setup.sh new file mode 100755 index 00000000..34540a7a --- /dev/null +++ b/contributor_setup.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +git config core.hooksPath .githooks