rust-raspberrypi-OS-tutorials/.githooks/pre-commit

24 lines
623 B
Plaintext
Raw Normal View History

2019-01-12 20:52:46 +00:00
#!/usr/bin/env ruby
2019-09-20 13:11:22 +00:00
# frozen_string_literal: true
2019-01-12 20:52:46 +00:00
2019-11-25 18:54:05 +00:00
# SPDX-License-Identifier: MIT OR Apache-2.0
#
2020-01-01 23:41:03 +00:00
# Copyright (c) 2018-2020 Andre Richter <andre.o.richter@gmail.com>
2019-09-20 13:11:22 +00:00
2020-01-09 21:11:56 +00:00
require 'rubygems'
require 'bundler/setup'
require_relative '../utils/devtool/copyright'
2019-01-12 20:52:46 +00:00
source_files_exts = ['.S', '.rs', '.rb']
2020-01-09 21:11:56 +00:00
staged_files = `git --no-pager diff --name-only --cached --diff-filter=d`.split(/\n/)
staged_files.select! do |f|
next if f.include?('build.rs')
2020-01-09 21:11:56 +00:00
f.include?('Makefile') ||
f.include?('Dockerfile') ||
source_files_exts.include?(File.extname(f))
2019-01-12 20:52:46 +00:00
end
2020-01-09 21:11:56 +00:00
exit(1) unless copyright_check_files(staged_files)