File tree 5 files changed +58
-0
lines changed
lib/overcommit/hook/pre_commit
spec/overcommit/hook/pre_commit
5 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
* Add [ ` Pronto ` ] ( https://github.com/mmozuras/pronto ) pre-commit hook
6
6
* Add [ ` hadolint ` ] ( https://github.com/lukasmartinelli/hadolint ) pre-commit hook
7
+ * Add [ ` license_finder ` ] ( https://github.com/pivotal/LicenseFinder ) pre-commit hook
7
8
* Use the ` core.hooksPath ` Git configuration option when installing hooks
8
9
9
10
## 0.39.1
Original file line number Diff line number Diff line change @@ -491,6 +491,7 @@ issue](https://github.com/brigade/overcommit/issues/238) for more details.
491
491
* [GoLint](lib/overcommit/hook/pre_commit/go_lint.rb)
492
492
* [GoVet](lib/overcommit/hook/pre_commit/go_vet.rb)
493
493
* [Hadolint](lib/overcommit/hook/pre_commit/hadolint.rb)
494
+ * [LicenseFinder](lib/overcommit/hook/pre_commit/license_finder.rb)
494
495
* [HamlLint](lib/overcommit/hook/pre_commit/haml_lint.rb)
495
496
* [HardTabs](lib/overcommit/hook/pre_commit/hard_tabs.rb)
496
497
* [Hlint](lib/overcommit/hook/pre_commit/hlint.rb)
Original file line number Diff line number Diff line change @@ -383,6 +383,21 @@ PreCommit:
383
383
install_command : ' gem install json'
384
384
include : ' **/*.json'
385
385
386
+ LicenseFinder :
387
+ enabled : false
388
+ description : ' Analyze with LicenseFinder'
389
+ required_executable : ' license_finder'
390
+ install_command : ' gem install license_finder'
391
+ include :
392
+ - ' Gemfile'
393
+ - ' requirements.txt'
394
+ - ' package.json'
395
+ - ' pom.xml'
396
+ - ' build.gradle'
397
+ - ' bower.json'
398
+ - ' Podfile'
399
+ - ' rebar.config'
400
+
386
401
LicenseHeader :
387
402
enabled : false
388
403
license_file : ' LICENSE.txt'
Original file line number Diff line number Diff line change
1
+ module Overcommit ::Hook ::PreCommit
2
+ # Runs LicenseFinder if any of your package manager declaration files have changed
3
+ # See more about LicenseFinder at https://github.com/pivotal/LicenseFinde
4
+ class LicenseFinder < Base
5
+ def run
6
+ result = execute ( command )
7
+ return :pass if result . success?
8
+ output = result . stdout + result . stderr
9
+ [ :fail , output ]
10
+ end
11
+ end
12
+ end
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+
3
+ describe Overcommit ::Hook ::PreCommit ::LicenseFinder do
4
+ let ( :config ) { Overcommit ::ConfigurationLoader . default_configuration }
5
+ let ( :context ) { double ( 'context' ) }
6
+ subject { described_class . new ( config , context ) }
7
+
8
+ context 'when license_finder exits successfully' do
9
+ before do
10
+ result = double ( 'result' )
11
+ result . stub ( :success? ) . and_return ( true )
12
+ subject . stub ( :execute ) . and_return ( result )
13
+ end
14
+
15
+ it { should pass }
16
+ end
17
+
18
+ context 'when license_finder runs unsucessfully' do
19
+ before do
20
+ result = double ( 'result' )
21
+ result . stub ( :success? ) . and_return ( false )
22
+ result . stub ( :stdout ) . and_return ( 'Some error message' )
23
+ result . stub ( :stderr ) . and_return ( '' )
24
+ subject . stub ( :execute ) . and_return ( result )
25
+ end
26
+
27
+ it { should fail_hook 'Some error message' }
28
+ end
29
+ end
You can’t perform that action at this time.
0 commit comments