overcommit 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2036b246cd2cc22654e25ef90f9217315c690ee6
4
- data.tar.gz: db142a34df320900e0e9941a5ae610b9dfd21b98
3
+ metadata.gz: b5f41c5306262e275c34566f2d7973a7993c3ef5
4
+ data.tar.gz: d89300cc765a7e790c94241265dcaecb6a8f2882
5
5
  SHA512:
6
- metadata.gz: c053edd85f3cbb401d70f63dad1a6c92ca2daa365d2b8694206539be76433c14a3e82f22cd70819cf851bb3ad5f8e8e87f19c4b672b2bbecd2eacd2bff3a6f5a
7
- data.tar.gz: 72e5403933d9bead975f48cfd011fd428d707e2f0e6a854e9487823a62ca26be2f44d87d6b10ebcc9c1950c7cf073028f0b22d6875cae5356dd1c7630375fb44
6
+ metadata.gz: b51462c1ea6bac7cde51b99e91d6b67cd77e521cb9d78dfd909b5d743ab6d1aa7582e6c393c8bc1f148d869017c1b9041057bbcac3343833c8fd81635c03a238
7
+ data.tar.gz: abee8bd8ee6e00ad8d06bccad9c3d0a3d0d2a5b616decd98c63dd501cf141305e6a62cb8f88199b6640057368ee169f4062a482d4e08e3ad506de215ba61585a
@@ -1,5 +1,6 @@
1
1
  require 'overcommit/configuration'
2
2
  require 'overcommit/console_methods'
3
+ require 'overcommit/errors'
3
4
  require 'overcommit/git_hook'
4
5
  require 'overcommit/hook_specific_check'
5
6
  require 'overcommit/installer'
@@ -2,13 +2,16 @@ require 'optparse'
2
2
 
3
3
  module Overcommit
4
4
  class CLI
5
+ include ConsoleMethods
6
+ attr_reader :options
7
+
5
8
  def initialize(arguments = [])
6
9
  @arguments = arguments
7
10
  @options = {}
8
11
  end
9
12
 
10
13
  def parse_arguments
11
- parser = OptionParser.new do |opts|
14
+ @parser = OptionParser.new do |opts|
12
15
  opts.banner = "Usage: #{opts.program_name} [options] target"
13
16
 
14
17
  opts.on_tail('-h', '--help', 'Show this message') do
@@ -20,6 +23,14 @@ module Overcommit
20
23
  exit 0
21
24
  end
22
25
 
26
+ opts.on('-l', '--list-templates', 'List built-in templates') do
27
+ Overcommit.config.templates.each_pair do |name, configuration|
28
+ bold name
29
+ puts YAML.dump(configuration), ''
30
+ end
31
+ exit 0
32
+ end
33
+
23
34
  opts.on('-a', '--all', 'Include all git hooks') do
24
35
  @options[:template] = 'all'
25
36
  end
@@ -54,40 +65,43 @@ module Overcommit
54
65
  end
55
66
 
56
67
  begin
57
- parser.parse!(@arguments)
68
+ @parser.parse!(@arguments)
58
69
 
59
70
  # Unconsumed arguments are our targets
60
71
  @options[:targets] = @arguments
61
72
  rescue OptionParser::InvalidOption => ex
62
- print_help parser.help, ex
73
+ print_help @parser.help, ex
63
74
  end
64
75
  end
65
76
 
66
77
  def run
67
78
  if @options[:targets].nil? || @options[:targets].empty?
68
- puts 'You must supply at least one directory to install into.'
69
- puts 'For example:', ''
70
- puts " #{File.basename($0)} <target directory>"
79
+ warning 'You must supply at least one directory to install into'
80
+ puts @parser.help
71
81
  exit 2
72
82
  end
73
83
 
74
84
  installer = Installer.new(@options)
75
85
 
76
86
  @options[:targets].each do |target|
77
- installer.install(target)
87
+ begin
88
+ installer.install(target)
89
+ rescue NotAGitRepoError => e
90
+ warning "Skipping #{target}: #{e}"
91
+ end
78
92
  end
79
93
 
80
- puts 'Installation complete.'
94
+ success 'Installation complete'
81
95
 
82
96
  rescue ArgumentError => ex
83
- puts "Installation failed: #{ex}"
97
+ error "Installation failed: #{ex}"
84
98
  exit 3
85
99
  end
86
100
 
87
101
  private
88
102
 
89
103
  def print_help(message, ex = nil)
90
- puts ex, '' if ex
104
+ error ex, '' if ex
91
105
  puts message
92
106
  exit 0
93
107
  end
@@ -0,0 +1,3 @@
1
+ class NotAGitRepoError < StandardError
2
+ # Nothing to see here
3
+ end
@@ -9,9 +9,12 @@ module Overcommit
9
9
 
10
10
  def install(target)
11
11
  absolute_target = File.expand_path(target)
12
- unless File.directory?(File.join(absolute_target, '.git'))
12
+ unless File.directory? absolute_target
13
+ raise NotAGitRepoError, 'is a directory'
14
+ end
13
15
 
14
- raise ArgumentError, "#{target} does not appear to be a git repository"
16
+ unless File.directory?(File.join(absolute_target, '.git'))
17
+ raise NotAGitRepoError, 'does not appear to be a git repository'
15
18
  end
16
19
 
17
20
  puts "Installing hooks into #{target}"
@@ -1,3 +1,3 @@
1
1
  module Overcommit
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Causes Engineering
@@ -9,8 +9,22 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2013-05-23 00:00:00.000000000 Z
12
- dependencies: []
13
- description: Overcommit is a utility to install and extend git hooks
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: Overcommit is a utility to install and extend Git hooks
14
28
  email: eng@causes.com
15
29
  executables:
16
30
  - overcommit
@@ -19,6 +33,7 @@ extra_rdoc_files: []
19
33
  files:
20
34
  - lib/overcommit.rb
21
35
  - lib/overcommit/utils.rb
36
+ - lib/overcommit/errors.rb
22
37
  - lib/overcommit/console_methods.rb
23
38
  - lib/overcommit/plugins/pre_commit/scss_lint.rb
24
39
  - lib/overcommit/plugins/pre_commit/causes_email.rb
@@ -83,6 +98,6 @@ rubyforge_project:
83
98
  rubygems_version: 2.0.2
84
99
  signing_key:
85
100
  specification_version: 4
86
- summary: Opinionated git hook manager
101
+ summary: Opinionated Git hook manager
87
102
  test_files: []
88
103
  has_rdoc: