git-duet 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,11 @@
1
+ # vim:fileencoding=utf-8
1
2
  require 'git/duet/pre_commit_command'
2
3
 
3
4
  describe Git::Duet::PreCommitCommand do
4
- subject do
5
- described_class.new(true)
6
- end
5
+ subject(:cmd) { described_class.new(true) }
7
6
 
8
7
  before :each do
9
- subject.stub(:in_repo_root) do |&block|
8
+ cmd.stub(:in_repo_root) do |&block|
10
9
  block.call
11
10
  end
12
11
  @old_seconds_ago_stale = ENV.delete('GIT_DUET_SECONDS_AGO_STALE')
@@ -17,20 +16,26 @@ describe Git::Duet::PreCommitCommand do
17
16
  ENV['GIT_DUET_SECONDS_AGO_STALE'] = @old_seconds_ago_stale
18
17
  end
19
18
 
20
- it 'should not require any params to initialize' do
19
+ it 'does not require any params to initialize' do
21
20
  expect { described_class.new }.to_not raise_error
22
21
  end
23
22
 
24
- it 'should do nothing if the env cache is not stale' do
25
- subject.stub(:exec_check).with(/git config duet\.env\.git/)
26
- subject.stub(:exec_check).with('git config duet.env.mtime').and_return(Time.now.to_i)
27
- subject.should_not_receive(:explode!)
28
- subject.execute!
23
+ it 'does nothing if the env cache is not stale' do
24
+ cmd.stub(:exec_check)
25
+ .with(/git config #{Git::Duet::Config.namespace}.git/)
26
+ cmd.stub(:exec_check)
27
+ .with("git config #{Git::Duet::Config.namespace}.mtime")
28
+ .and_return(Time.now.to_i)
29
+ cmd.should_not_receive(:explode!)
30
+ cmd.execute!
29
31
  end
30
32
 
31
- it 'should explode if the env cache does not exist' do
32
- subject.stub(:exec_check).with(/git config duet\.env\.git/)
33
- subject.stub(:exec_check).with('git config duet.env.mtime').and_raise(StandardError)
34
- expect { subject.execute! }.to raise_error(Git::Duet::ScriptDieError)
33
+ it 'explodes if the env cache does not exist' do
34
+ cmd.stub(:exec_check)
35
+ .with(/git config #{Git::Duet::Config.namespace}.git/)
36
+ cmd.stub(:exec_check)
37
+ .with("git config #{Git::Duet::Config.namespace}.mtime")
38
+ .and_raise(StandardError)
39
+ expect { cmd.execute! }.to raise_error(Git::Duet::ScriptDieError)
35
40
  end
36
41
  end
@@ -1,124 +1,169 @@
1
+ # vim:fileencoding=utf-8
1
2
  require 'git/duet/solo_command'
2
3
  require 'support/author_mapper_helper'
3
4
 
4
5
  describe Git::Duet::SoloCommand do
5
6
  include SpecSupport::AuthorMapperHelper
6
7
 
7
- let :soloist do
8
- random_author
9
- end
8
+ let(:soloist) { random_author }
10
9
 
11
- subject do
12
- described_class.new(soloist)
13
- end
10
+ subject(:cmd) { described_class.new(soloist) }
14
11
 
15
12
  before :each do
16
- subject.stub(:author_mapper => double('author mapper').tap do |am|
17
- am.stub(:map => author_mapping)
13
+ cmd.stub(author_mapper: double('author mapper').tap do |am|
14
+ am.stub(map: author_mapping)
18
15
  end)
19
- subject.stub(:` => '')
20
- subject.stub(:report_env_vars)
21
- subject.stub(:in_repo_root) do |&block|
16
+ cmd.stub(:` => '')
17
+ cmd.stub(:report_env_vars)
18
+ cmd.stub(:in_repo_root) do |&block|
22
19
  block.call
23
20
  end
24
21
  end
25
22
 
26
- it 'should require soloist initials' do
23
+ it 'requires soloist initials' do
27
24
  expect { described_class.new }.to raise_error(ArgumentError)
28
25
  end
29
26
 
30
- it 'should respond to `execute!`' do
31
- subject.should respond_to(:execute!)
27
+ it 'responds to `execute!`' do
28
+ cmd.should respond_to(:execute!)
32
29
  end
33
30
 
34
- it 'should (privately) respond to `write_env_vars`' do
35
- subject.private_methods.map(&:to_sym).should include(:write_env_vars)
31
+ it '(privately) responds to `write_env_vars`' do
32
+ cmd.private_methods.map(&:to_sym).should include(:write_env_vars)
36
33
  end
37
34
 
38
- it 'should set the soloist name as git config user.name' do
39
- subject.stub(:`).with(/git config user\.email/)
40
- subject.stub(:`).with(/git config --unset-all duet\.env/)
41
- subject.should_receive(:`).with("git config user.name '#{author_mapping[soloist][:name]}'")
42
- subject.execute!
35
+ it 'sets the soloist name as git config user.name' do
36
+ cmd.stub(:`).with(/git config user\.email/)
37
+ cmd.stub(:`).with(/git config --unset-all #{Git::Duet::Config.namespace}/)
38
+ cmd.should_receive(:`)
39
+ .with("git config user.name '#{author_mapping[soloist][:name]}'")
40
+ cmd.execute!
43
41
  end
44
42
 
45
- it 'should set the soloist email as git config user.email' do
46
- subject.stub(:`).with(/git config user\.name/)
47
- subject.stub(:`).with(/git config --unset-all duet\.env/)
48
- subject.should_receive(:`).with("git config user.email '#{author_mapping[soloist][:email]}'")
49
- subject.execute!
43
+ it 'sets the soloist email as git config user.email' do
44
+ cmd.stub(:`).with(/git config user\.name/)
45
+ cmd.stub(:`).with(/git config --unset-all #{Git::Duet::Config.namespace}/)
46
+ cmd.should_receive(:`)
47
+ .with("git config user.email '#{author_mapping[soloist][:email]}'")
48
+ cmd.execute!
50
49
  end
51
50
 
52
- it 'should unset the committer name' do
53
- subject.stub(:`).with(/git config user\.name/)
54
- subject.stub(:`).with(/git config user\.email/)
55
- subject.stub(:`).with(/git config --unset-all duet\.env\.git-committer-email/)
56
- subject.should_receive(:`).with('git config --unset-all duet.env.git-committer-name')
57
- subject.execute!
51
+ it 'unsets the committer name' do
52
+ cmd.stub(:`).with(/git config user\.name/)
53
+ cmd.stub(:`).with(/git config user\.email/)
54
+ cmd.stub(:`)
55
+ .with(/git config --unset-all #{Git::Duet::Config
56
+ .namespace}.git-committer-email/)
57
+ cmd.should_receive(:`)
58
+ .with("git config --unset-all #{Git::Duet::Config
59
+ .namespace}.git-committer-name")
60
+ cmd.execute!
58
61
  end
59
62
 
60
- it 'should unset the committer email' do
61
- subject.stub(:`).with(/git config user\.name/)
62
- subject.stub(:`).with(/git config user\.email/)
63
- subject.stub(:`).with(/git config --unset-all duet\.env\.git-committer-name/)
64
- subject.should_receive(:`).with('git config --unset-all duet.env.git-committer-email')
65
- subject.execute!
63
+ it 'unsets the committer email' do
64
+ cmd.stub(:`).with(/git config user\.name/)
65
+ cmd.stub(:`).with(/git config user\.email/)
66
+ cmd.stub(:`)
67
+ .with(/git config --unset-all #{Git::Duet::Config
68
+ .namespace}.git-committer-name/)
69
+ cmd.should_receive(:`)
70
+ .with("git config --unset-all #{Git::Duet::Config
71
+ .namespace}.git-committer-email")
72
+ cmd.execute!
66
73
  end
67
74
 
68
- it 'should report env vars to $stdout' do
69
- subject.unstub(:report_env_vars)
70
- $stdout.should_receive(:puts).with(/^GIT_AUTHOR_NAME='#{author_mapping[soloist][:name]}'/)
71
- $stdout.should_receive(:puts).with(/^GIT_AUTHOR_EMAIL='#{author_mapping[soloist][:email]}'/)
72
- subject.execute!
75
+ it 'reports env vars to $stdout' do
76
+ cmd.unstub(:report_env_vars)
77
+ $stdout.should_receive(:puts)
78
+ .with(/^GIT_AUTHOR_NAME='#{author_mapping[soloist][:name]}'/)
79
+ $stdout.should_receive(:puts)
80
+ .with(/^GIT_AUTHOR_EMAIL='#{author_mapping[soloist][:email]}'/)
81
+ cmd.execute!
73
82
  end
74
83
 
75
- it 'should set the soloist as author in custom git config' do
76
- subject.should_receive(:write_env_vars)
77
- subject.execute!
84
+ it 'sets the soloist as author in custom git config' do
85
+ cmd.should_receive(:write_env_vars)
86
+ cmd.execute!
78
87
  end
79
88
 
80
89
  context 'when soloist is missing' do
81
90
  let(:soloist) { 'bzzzrt' }
82
91
 
83
92
  it 'aborts' do
84
- subject.stub(:error => nil)
85
- expect { subject.execute! }.to raise_error(Git::Duet::ScriptDieError)
93
+ cmd.stub(error: nil)
94
+ expect { cmd.execute! }.to raise_error(Git::Duet::ScriptDieError)
86
95
  end
87
96
  end
88
97
 
89
- context 'when configured to operate on the global config' do
90
- subject do
91
- described_class.new(soloist, false, true)
98
+ context 'when given no arguments' do
99
+ let(:soloist) { nil }
100
+
101
+ it 'shows the current duet author settings' do
102
+ git_config_output = <<-EOF.gsub(/^ {8}/, '')
103
+ #{Git::Duet::Config.namespace}.git-author-name Test Author
104
+ #{Git::Duet::Config.namespace}.git-author-email author@test.com
105
+ #{Git::Duet::Config.namespace}.mtime 138039#{rand(1000..9999)}
106
+ EOF
107
+
108
+ cmd.stub(:`)
109
+ .with("git config --get-regexp #{Git::Duet::Config.namespace}") do
110
+ git_config_output
111
+ end
112
+ $stdout.should_receive(:puts).with(git_config_output)
113
+
114
+ cmd.execute!
92
115
  end
116
+ end
93
117
 
94
- it 'should set the soloist name as global git config user.name' do
95
- subject.stub(:`).with(/git config --global user\.email/)
96
- subject.stub(:`).with(/git config --global --unset-all duet\.env/)
97
- subject.should_receive(:`).with("git config --global user.name '#{author_mapping[soloist][:name]}'")
98
- subject.execute!
118
+ context 'when configured to operate on the global config' do
119
+ subject(:cmd) { described_class.new(soloist, false, true) }
120
+
121
+ it 'sets the soloist name as global git config user.name' do
122
+ cmd.stub(:`).with(/git config --global user\.email/)
123
+ cmd.stub(:`)
124
+ .with(/git config --global --unset-all #{Git::Duet::Config.namespace}/)
125
+ soloist_name = author_mapping[soloist][:name]
126
+ cmd.should_receive(:`)
127
+ .with("git config --global user.name '#{soloist_name}'")
128
+ cmd.execute!
99
129
  end
100
130
 
101
- it 'should set the soloist email as global git config user.email' do
102
- subject.stub(:`).with(/git config --global user\.name/)
103
- subject.stub(:`).with(/git config --global --unset-all duet\.env/)
104
- subject.should_receive(:`).with("git config --global user.email '#{author_mapping[soloist][:email]}'")
105
- subject.execute!
131
+ it 'sets the soloist email as global git config user.email' do
132
+ cmd.stub(:`).with(/git config --global user\.name/)
133
+ cmd.stub(:`)
134
+ .with(/git config --global --unset-all #{Git::Duet::Config.namespace}/)
135
+ soloist_email = author_mapping[soloist][:email]
136
+ cmd.should_receive(:`)
137
+ .with("git config --global user.email '#{soloist_email}'")
138
+ cmd.execute!
106
139
  end
107
140
 
108
- it 'should unset the global committer name' do
109
- subject.stub(:`).with(/git config --global user\.name/)
110
- subject.stub(:`).with(/git config --global user\.email/)
111
- subject.stub(:`).with(/git config --global --unset-all duet\.env\.git-committer-email/)
112
- subject.should_receive(:`).with('git config --global --unset-all duet.env.git-committer-name')
113
- subject.execute!
141
+ it 'unsets the global committer name' do
142
+ cmd.stub(:`).with(/git config --global user\.name/)
143
+ cmd.stub(:`).with(/git config --global user\.email/)
144
+ cmd.stub(:`)
145
+ .with(
146
+ /git config --global --unset-all #{Git::Duet::Config
147
+ .namespace}.git-committer-email/
148
+ )
149
+ cmd.should_receive(:`)
150
+ .with('git config --global --unset-all ' <<
151
+ "#{Git::Duet::Config.namespace}.git-committer-name")
152
+ cmd.execute!
114
153
  end
115
154
 
116
- it 'should unset the global committer email' do
117
- subject.stub(:`).with(/git config --global user\.name/)
118
- subject.stub(:`).with(/git config --global user\.email/)
119
- subject.stub(:`).with(/git config --global --unset-all duet\.env\.git-committer-name/)
120
- subject.should_receive(:`).with('git config --global --unset-all duet.env.git-committer-email')
121
- subject.execute!
155
+ it 'unsets the global committer email' do
156
+ cmd.stub(:`).with(/git config --global user\.name/)
157
+ cmd.stub(:`).with(/git config --global user\.email/)
158
+ cmd.stub(:`)
159
+ .with(
160
+ /git config --global --unset-all #{Git::Duet::Config
161
+ .namespace}.git-committer-name/
162
+ )
163
+ cmd.should_receive(:`)
164
+ .with('git config --global --unset-all ' <<
165
+ "#{Git::Duet::Config.namespace}.git-committer-email")
166
+ cmd.execute!
122
167
  end
123
168
  end
124
169
  end
@@ -1,22 +1,9 @@
1
+ # vim:fileencoding=utf-8
2
+
1
3
  require 'rubygems'
2
4
  require 'bundler/setup'
3
5
 
4
- require 'rbconfig'
5
-
6
- unless RUBY_PLATFORM == 'java'
7
- require 'simplecov'
8
- end
9
-
10
- RSpec.configure do |c|
11
- if !ENV['TRAVIS']
12
- if RbConfig::CONFIG['host_os'] =~ /darwin/i
13
- c.formatter = 'NyanCatMusicFormatter'
14
- else
15
- # No music allowed for neckbeards or polo shirts.
16
- c.formatter = 'NyanCatFormatter'
17
- end
18
- end
19
- end
6
+ require 'simplecov' unless RUBY_PLATFORM == 'java'
20
7
 
21
8
  $stderr.puts <<EOWARNING
22
9
  ----------------------------------------------------------------------------
@@ -1,28 +1,32 @@
1
+ # vim:fileencoding=utf-8
2
+
1
3
  module SpecSupport
2
4
  module AuthorMapperHelper
3
5
  def random_author
4
6
  author_mapping.keys.send(RUBY_VERSION < '1.9' ? :choice : :sample)
5
7
  end
6
8
 
7
- def author_mapping
8
- {
9
- 'jd' => {
10
- :name => 'Jane Doe',
11
- :email => 'jane@awesome.biz'
12
- },
13
- 'fb' => {
14
- :name => 'Frances Bar',
15
- :email => 'frances@awesometown.me'
16
- },
17
- 'qx' => {
18
- :name => 'Quincy Xavier',
19
- :email => 'qx@awesometown.me'
20
- },
21
- 'hb' => {
22
- :name => 'Hampton Bones',
23
- :email => 'h.bones@awesometown.me'
24
- }
9
+ AUTHOR_MAPPING = {
10
+ 'jd' => {
11
+ name: 'Jane Doe',
12
+ email: 'jane@awesome.biz'
13
+ },
14
+ 'fb' => {
15
+ name: 'Frances Bar',
16
+ email: 'frances@awesometown.me'
17
+ },
18
+ 'qx' => {
19
+ name: 'Quincy Xavier',
20
+ email: 'qx@awesometown.me'
21
+ },
22
+ 'hb' => {
23
+ name: 'Hampton Bones',
24
+ email: 'h.bones@awesometown.me'
25
25
  }
26
+ }
27
+
28
+ def author_mapping
29
+ AUTHOR_MAPPING.clone
26
30
  end
27
31
  end
28
32
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-duet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dan Buch
@@ -12,86 +11,76 @@ authors:
12
11
  autorequire:
13
12
  bindir: bin
14
13
  cert_chain: []
15
- date: 2013-07-29 00:00:00.000000000 Z
14
+ date: 2013-10-01 00:00:00.000000000 Z
16
15
  dependencies:
17
16
  - !ruby/object:Gem::Dependency
18
- name: nyan-cat-formatter
17
+ name: rake
19
18
  requirement: !ruby/object:Gem::Requirement
20
- none: false
21
19
  requirements:
22
- - - ! '>='
20
+ - - '>='
23
21
  - !ruby/object:Gem::Version
24
22
  version: '0'
25
23
  type: :development
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
- - - ! '>='
27
+ - - '>='
31
28
  - !ruby/object:Gem::Version
32
29
  version: '0'
33
30
  - !ruby/object:Gem::Dependency
34
- name: rake
31
+ name: rspec
35
32
  requirement: !ruby/object:Gem::Requirement
36
- none: false
37
33
  requirements:
38
- - - ! '>='
34
+ - - '>='
39
35
  - !ruby/object:Gem::Version
40
36
  version: '0'
41
37
  type: :development
42
38
  prerelease: false
43
39
  version_requirements: !ruby/object:Gem::Requirement
44
- none: false
45
40
  requirements:
46
- - - ! '>='
41
+ - - '>='
47
42
  - !ruby/object:Gem::Version
48
43
  version: '0'
49
44
  - !ruby/object:Gem::Dependency
50
- name: rspec
45
+ name: rubocop
51
46
  requirement: !ruby/object:Gem::Requirement
52
- none: false
53
47
  requirements:
54
- - - ! '>='
48
+ - - '>='
55
49
  - !ruby/object:Gem::Version
56
50
  version: '0'
57
51
  type: :development
58
52
  prerelease: false
59
53
  version_requirements: !ruby/object:Gem::Requirement
60
- none: false
61
54
  requirements:
62
- - - ! '>='
55
+ - - '>='
63
56
  - !ruby/object:Gem::Version
64
57
  version: '0'
65
58
  - !ruby/object:Gem::Dependency
66
59
  name: pry
67
60
  requirement: !ruby/object:Gem::Requirement
68
- none: false
69
61
  requirements:
70
- - - ! '>='
62
+ - - '>='
71
63
  - !ruby/object:Gem::Version
72
64
  version: '0'
73
65
  type: :development
74
66
  prerelease: false
75
67
  version_requirements: !ruby/object:Gem::Requirement
76
- none: false
77
68
  requirements:
78
- - - ! '>='
69
+ - - '>='
79
70
  - !ruby/object:Gem::Version
80
71
  version: '0'
81
72
  - !ruby/object:Gem::Dependency
82
73
  name: simplecov
83
74
  requirement: !ruby/object:Gem::Requirement
84
- none: false
85
75
  requirements:
86
- - - ! '>='
76
+ - - '>='
87
77
  - !ruby/object:Gem::Version
88
78
  version: '0'
89
79
  type: :development
90
80
  prerelease: false
91
81
  version_requirements: !ruby/object:Gem::Requirement
92
- none: false
93
82
  requirements:
94
- - - ! '>='
83
+ - - '>='
95
84
  - !ruby/object:Gem::Version
96
85
  version: '0'
97
86
  description: Pair programming git identity thingy
@@ -105,15 +94,15 @@ executables:
105
94
  - git-duet-commit
106
95
  - git-duet-install-hook
107
96
  - git-duet-pre-commit
108
- - git-duet-pre-commit-tk
109
97
  - git-solo
110
98
  extensions: []
111
99
  extra_rdoc_files: []
112
100
  files:
113
101
  - .gitignore
114
102
  - .jrubyrc
115
- - .rbenv-version
116
103
  - .rspec
104
+ - .rubocop.yml
105
+ - .ruby-version
117
106
  - .simplecov
118
107
  - .travis.yml
119
108
  - Gemfile
@@ -124,7 +113,6 @@ files:
124
113
  - bin/git-duet-commit
125
114
  - bin/git-duet-install-hook
126
115
  - bin/git-duet-pre-commit
127
- - bin/git-duet-pre-commit-tk
128
116
  - bin/git-solo
129
117
  - git-duet.gemspec
130
118
  - lib/git-duet.rb
@@ -133,9 +121,9 @@ files:
133
121
  - lib/git/duet/cli.rb
134
122
  - lib/git/duet/command_methods.rb
135
123
  - lib/git/duet/commit_command.rb
124
+ - lib/git/duet/config.rb
136
125
  - lib/git/duet/duet_command.rb
137
126
  - lib/git/duet/install_hook_command.rb
138
- - lib/git/duet/key_error.rb
139
127
  - lib/git/duet/pre_commit_command.rb
140
128
  - lib/git/duet/script_die_error.rb
141
129
  - lib/git/duet/solo_command.rb
@@ -149,33 +137,29 @@ files:
149
137
  - spec/lib/git/duet/solo_command_spec.rb
150
138
  - spec/spec_helper.rb
151
139
  - spec/support/author_mapper_helper.rb
152
- homepage: ''
140
+ homepage: https://github.com/modcloth/git-duet
153
141
  licenses:
154
142
  - MIT
143
+ metadata: {}
155
144
  post_install_message:
156
145
  rdoc_options: []
157
146
  require_paths:
158
147
  - lib
159
148
  required_ruby_version: !ruby/object:Gem::Requirement
160
- none: false
161
149
  requirements:
162
- - - ! '>='
150
+ - - '>='
163
151
  - !ruby/object:Gem::Version
164
- version: 1.8.7
152
+ version: 1.9.3
165
153
  required_rubygems_version: !ruby/object:Gem::Requirement
166
- none: false
167
154
  requirements:
168
- - - ! '>='
155
+ - - '>='
169
156
  - !ruby/object:Gem::Version
170
157
  version: '0'
171
- segments:
172
- - 0
173
- hash: 4378173393483041112
174
158
  requirements: []
175
159
  rubyforge_project:
176
- rubygems_version: 1.8.23
160
+ rubygems_version: 2.0.3
177
161
  signing_key:
178
- specification_version: 3
162
+ specification_version: 4
179
163
  summary: Pair harmoniously! Decide who's driving. Commit along the way. Don't make
180
164
  a mess of the repository history.
181
165
  test_files: