Skip to content

Commit 80766b4

Browse files
ajgonsds
authored andcommitted
Use License word instead of Licence
In `LicenceHeader` hook, we have a word `Licence`, but we should use `License`. Both forms are valid, but the `License` word became more or less industry standard, and we should stick to it, to avoid confusion.
1 parent 9c1d8fa commit 80766b4

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* Add `FixMe` pre-commit hook, to ensure that no "token" words slips through.
66
These strings are things you should fix now, not later.
77
* Add [`YAMLLint`](https://github.com/adrienverge/yamllint) pre-commit hook
8-
* Add `LicenceHeader` pre-commit enforcement to ensure open source projects
9-
contain proper licence comments.
8+
* Add `LicenseHeader` pre-commit enforcement to ensure open source projects
9+
contain proper license comments.
1010
* Add [`Foodcritic`](http://www.foodcritic.io/) pre-commit hook
1111
* Fix `CapitalizedSubject` to not fail when commit message starts with one or
1212
more empty lines

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ issue](https://github.com/brigade/overcommit/issues/238) for more details.
504504
* [JsLint](lib/overcommit/hook/pre_commit/js_lint.rb)
505505
* [Jsl](lib/overcommit/hook/pre_commit/jsl.rb)
506506
* [JsonSyntax](lib/overcommit/hook/pre_commit/json_syntax.rb)
507-
* [LicenceHeader](lib/overcommit/hook/pre_commit/licence_header.rb)
507+
* [LicenseHeader](lib/overcommit/hook/pre_commit/license_header.rb)
508508
* [LocalPathsInGemfile](lib/overcommit/hook/pre_commit/local_paths_in_gemfile.rb)
509509
* [Mdl](lib/overcommit/hook/pre_commit/mdl.rb)
510510
* [`*`MergeConflicts](lib/overcommit/hook/pre_commit/merge_conflicts.rb)

config/default.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,10 @@ PreCommit:
381381
install_command: 'gem install json'
382382
include: '**/*.json'
383383

384-
LicenceHeader:
384+
LicenseHeader:
385385
enabled: false
386-
licence_file: 'LICENSE.txt'
387-
description: 'Check source files for licence headers'
386+
license_file: 'LICENSE.txt'
387+
description: 'Check source files for license headers'
388388

389389
LocalPathsInGemfile:
390390
enabled: false

lib/overcommit/hook/pre_commit/licence_header.rb renamed to lib/overcommit/hook/pre_commit/license_header.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
11
module Overcommit::Hook::PreCommit
2-
# Checks for licence headers in source files
3-
class LicenceHeader < Base
2+
# Checks for license headers in source files
3+
class LicenseHeader < Base
44
def run
55
begin
6-
licence_contents = licence_lines
6+
license_contents = license_lines
77
rescue Errno::ENOENT
8-
return :fail, "Unable to load licence file #{licence_file}"
8+
return :fail, "Unable to load license file #{license_file}"
99
end
1010

1111
messages = applicable_files.map do |file|
12-
check_file(file, licence_contents)
12+
check_file(file, license_contents)
1313
end.compact
1414

1515
return :fail, messages.join("\n") if messages.any?
1616

1717
:pass
1818
end
1919

20-
def check_file(file, licence_contents)
20+
def check_file(file, license_contents)
2121
File.readlines(file).each_with_index do |l, i|
22-
if i >= licence_contents.length
22+
if i >= license_contents.length
2323
break
2424
end
2525

2626
l.chomp!
27-
unless l.end_with?(licence_contents[i])
27+
unless l.end_with?(license_contents[i])
2828
message = "#{file} missing header contents from line #{i} of "\
29-
"#{licence_file}: #{licence_contents[i]}"
29+
"#{license_file}: #{license_contents[i]}"
3030
return message
3131
end
3232
end
3333
end
3434

35-
def licence_file
36-
config['licence_file']
35+
def license_file
36+
config['license_file']
3737
end
3838

39-
def licence_lines
40-
@licence_regex ||= begin
41-
file_root = Overcommit::Utils.convert_glob_to_absolute(licence_file)
39+
def license_lines
40+
@license_regex ||= begin
41+
file_root = Overcommit::Utils.convert_glob_to_absolute(license_file)
4242
File.read(file_root).split("\n")
4343
end
4444
end

spec/overcommit/hook/pre_commit/licence_header_spec.rb renamed to spec/overcommit/hook/pre_commit/license_header_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper'
22

3-
describe Overcommit::Hook::PreCommit::LicenceHeader do
3+
describe Overcommit::Hook::PreCommit::LicenseHeader do
44
let(:config) { Overcommit::ConfigurationLoader.default_configuration }
55
let(:context) { double('context') }
66
subject { described_class.new(config, context) }
@@ -41,7 +41,7 @@
4141
it { should pass }
4242
end
4343

44-
context 'when a file is missing a licence header' do
44+
context 'when a file is missing a license header' do
4545
before do
4646
File.open(file, 'w') { |f| f.write('Some text without a license') }
4747
end

0 commit comments

Comments
 (0)