From 488ba89862d99a0be831d2325577e9314e1c6f31 Mon Sep 17 00:00:00 2001 From: Isaac Stone Date: Fri, 8 Mar 2019 22:37:32 -0800 Subject: [PATCH 1/2] Don't add a header to empty files Python requries package folders to have an '__init__.py' file, but usually this file is empty. Since there is no code in the file adding a copyright header seemed to me to be a bit non-sensicle. I suppose this could be a flag, but I really can't think of why anyone should need a copyright header for an empty file? --- lib/copyright_header/parser.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/copyright_header/parser.rb b/lib/copyright_header/parser.rb index 5b7b4d0..ba9c9e7 100644 --- a/lib/copyright_header/parser.rb +++ b/lib/copyright_header/parser.rb @@ -26,6 +26,7 @@ module CopyrightHeader class FileNotFoundException < Exception; end class ExistingLicenseException < Exception; end + class EmptyFileException < Exception; end class License @lines = [] @@ -86,6 +87,10 @@ def add(license) return nil end + if @contents.strip.empty? + raise EmptyFileException.new("file is empty") + end + text = "" if @config.has_key?(:after) && @config[:after].instance_of?(Array) copyright_written = false From e6806fabe5a751304ae5ff5904a75def11da23a7 Mon Sep 17 00:00:00 2001 From: Isaac Stone Date: Mon, 11 Mar 2019 13:52:42 -0700 Subject: [PATCH 2/2] updated github-linguist --- copyright-header.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/copyright-header.gemspec b/copyright-header.gemspec index 770c21f..c743473 100644 --- a/copyright-header.gemspec +++ b/copyright-header.gemspec @@ -24,5 +24,5 @@ Gem::Specification.new do |s| s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.extra_rdoc_files = ['README.md', 'LICENSE', 'AUTHORS', 'contrib/syntax.yml' ] s.require_paths = ["lib"] - s.add_runtime_dependency('github-linguist','~>6.0') + s.add_runtime_dependency('github-linguist','~>7.2') end