minigit 0.0.3 → 0.0.4

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.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTliYWIzNjkxMTA1NWZiMGI4OGM1ZjcxZDhiYjEwYTllOGM5ZDE3MQ==
5
+ data.tar.gz: !binary |-
6
+ MTRjNDczMjYzZDRkZDI3OWM4ZmI3OWFiNmFlMWNjZjgwYjA5MTMwZA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MDMxODFkZjI3ZjRjZDRjMjQ4MmIyYTJhMDY4M2IyZjY5YzNkZjU5ZWZhNTU1
10
+ NjEzYzE3NmFmMjRhMDJjYWZjNzNiYjNiMmU2OTEzYWQxOWQ1OTNiYzhmYzE2
11
+ NWRkNDU0ZjJmMzgxNmNiMmU0YzY5NDcxZTRjZDgyZDEzYmE3NmY=
12
+ data.tar.gz: !binary |-
13
+ MmI3MDRhZmVhYTc5N2IxMzgzODhiMmJlNzI1ZWE2MzRkNmI3NDJmNzMzMjkz
14
+ YTA3MDFmOGZlMjE0ZjQwMTYzODMxNGI3ZDM0ODk4OTVmOGNhOWY5Nzg0Y2U1
15
+ NzNhNjQ2YWEwMmZlZmI3NzFmNGU2ZDA5MDZjYWY3MTA0MjliMTM=
@@ -1,13 +1,21 @@
1
+ ---
1
2
  language: ruby
2
3
  bundler_args: --without development_workstation
3
4
  rvm:
4
- - 1.8.7
5
- - 1.9.2
6
- - 1.9.3
7
- - 2.0.0
8
- - ree
9
- - jruby-18mode
10
- - jruby-19mode
11
- - jruby-head
12
- - rbx-18mode
13
- - rbx-19mode
5
+ - 1.8.7
6
+ - 1.9.2
7
+ - 1.9.3
8
+ - 2.0.0
9
+ - ree
10
+ - jruby-18mode
11
+ - jruby-19mode
12
+ - jruby-head
13
+ - rbx-18mode
14
+ - rbx-19mode
15
+ notifications:
16
+ hipchat:
17
+ secure: ! 'bGTLLC9qlBlOktqm1uuOmh1CkBASBxVzeTZrN45goL570X/uNnLXY54tly65
18
+
19
+ P2KaBzbWvUmBm2sy3sVIv0bOGP04eOP5nl/lvmRrr6GdonErhUqWDklFZBM3
20
+
21
+ 29W4yd8Tr+1rHhCnwSGbhEDN9Q8UGVN+58rTPrwCFXBeidLBtjQ='
@@ -0,0 +1,25 @@
1
+ Changes
2
+ =======
3
+
4
+ 0.0.4
5
+ -----
6
+
7
+ - Hash-like access to `git config` (Marta Paciorkowska)
8
+ - Documentation fixes
9
+ - (internal) use Minitest 5
10
+
11
+ 0.0.3
12
+ -----
13
+
14
+ - Debug mode (`MiniGit.debug`)
15
+
16
+ 0.0.2
17
+ -----
18
+
19
+ - JRuby support
20
+ - (internal) Refactoring
21
+
22
+ 0.0.1
23
+ -----
24
+
25
+ - Initial release
@@ -0,0 +1,17 @@
1
+ # How to contribute
2
+ Thank you for wanting to contribute! These are just a few guidelines that we'd like contributors to follow.
3
+
4
+ ## Making changes
5
+
6
+ * Fork the repo.
7
+ * Create a branch from the develop branch and name it 'feature/name-of-feature': `git checkout -b feature/my-new-feature` (We follow [this branching model] (http://nvie.com/posts/a-successful-git-branching-model/))
8
+ * Make sure you test your new feature.
9
+ * Commit your changes together with specs for them: `git commit -am 'Add some feature'`
10
+
11
+ ## Submitting changes
12
+
13
+ * Push your changes to your feature branch.
14
+ * Submit a pull request to the develop repository. Describe your feature in the pull request. Make sure you commit the specs.
15
+ * A pull request does not necessarily need to represent the final, finished feature. Feel free to treat it as a base for discussion.
16
+
17
+ ### Thank you for contributing!
data/Gemfile CHANGED
@@ -5,6 +5,6 @@ gemspec
5
5
 
6
6
  # Optional development environment
7
7
  group :development_workstation do
8
+ gem "pry-stack_explorer", :require => false
8
9
  gem "pry", :require => false
9
- gem "minitest-ansi"
10
10
  end
data/README.md CHANGED
@@ -87,8 +87,8 @@ git.capturing.branch # => "* master\n"
87
87
 
88
88
  ```ruby
89
89
  cgit = MiniGit::Capturing.new
90
- git.branch # => "* master\n"
91
- git.noncapturing.branch # => nil (output shown to the terminal)
90
+ cgit.branch # => "* master\n"
91
+ cgit.noncapturing.branch # => nil (output shown to the terminal)
92
92
  ```
93
93
 
94
94
  You can also provide a path specifying the Git repo. It can be:
@@ -96,7 +96,7 @@ You can also provide a path specifying the Git repo. It can be:
96
96
  * a working directory
97
97
  * a file in or subdirectory of a working directory
98
98
  * a bare repository
99
- * a `.git` directory (which will be trated as a bare repository)
99
+ * a `.git` directory (which will be treated as a bare repository)
100
100
 
101
101
  MiniGit will find the Git directory and work tree automagically by
102
102
  calling out to `git rev-parse --git-dir --show-toplevel`, will set
@@ -113,6 +113,22 @@ MiniGit.new('../vendorificator').log :n => 1, :oneline => true
113
113
  MiniGit.new('../vendorificator').capturing.log :n => 1, :oneline => true
114
114
  # => "b485d32 Merge branch 'release/0.1.1' into develop\n"
115
115
  ```
116
+ ### Git config hash-like access
117
+
118
+ You can call, modify and create new git config attributes with simple hash-like syntax:
119
+
120
+ ```ruby
121
+ git = MiniGit.new
122
+ git['user.email'] # => returns the user email assigned to the repository
123
+ git['user.email'] = 'foo@bar' # changes the user.email to foo@bar
124
+ ```
125
+
126
+ The same works on the class itself:
127
+
128
+ ```ruby
129
+ MiniGit['user.email'] # => "foo@bar"
130
+ MiniGit['user.email'] = 'foo@bar' # changes the user.email to foo@bar
131
+ ```
116
132
 
117
133
  ### Git command
118
134
 
@@ -185,9 +201,4 @@ ENV['GIT_PAGER'] = ''
185
201
 
186
202
  ## Contributing
187
203
 
188
- 1. Fork it
189
- 2. Create your feature branch (`git checkout -b my-new-feature`)
190
- 3. Commit your changes (`git commit -am 'Add some feature'`), together
191
- with specs for them
192
- 4. Push to the branch (`git push origin my-new-feature`)
193
- 5. Create new Pull Request
204
+ See CONTRIBUTING.md
@@ -20,6 +20,14 @@ class MiniGit
20
20
  _myself.git(*args)
21
21
  end
22
22
 
23
+ def [](arg)
24
+ _myself[arg]
25
+ end
26
+
27
+ def []=(key, value)
28
+ _myself[key] = value
29
+ end
30
+
23
31
  protected
24
32
 
25
33
  def _myself
@@ -29,7 +37,7 @@ class MiniGit
29
37
 
30
38
  class GitError < RuntimeError
31
39
  attr_reader :command, :status, :info
32
- def initialize(command, status, info={})
40
+ def initialize(command=[], status=nil, info={})
33
41
  @status = status.dup rescue status.to_s
34
42
  @command = command
35
43
  @info = info
@@ -114,9 +122,10 @@ class MiniGit
114
122
  end
115
123
 
116
124
  def capturing
117
- @capturing ||= Capturing.new(:git_command => @git_command,
118
- :git_dir => @git_dir,
119
- :git_work_tree => @git_work_tree)
125
+ @capturing ||= Capturing.new(
126
+ :git_command => @git_command,
127
+ :git_dir => @git_dir,
128
+ :git_work_tree => @git_work_tree)
120
129
  end
121
130
 
122
131
  def noncapturing
@@ -135,12 +144,29 @@ class MiniGit
135
144
  end
136
145
 
137
146
  def noncapturing
138
- @noncapturing ||= MiniGit.new(:git_command => @git_command,
139
- :git_dir => @git_dir,
140
- :git_work_tree => @git_work_tree)
147
+ @noncapturing ||= MiniGit.new(
148
+ :git_command => @git_command,
149
+ :git_dir => @git_dir,
150
+ :git_work_tree => @git_work_tree)
141
151
  end
142
152
  end
143
153
 
154
+ def [](arg)
155
+ begin
156
+ self.capturing.config(arg).strip
157
+ rescue MiniGit::GitError
158
+ nil
159
+ end
160
+ end
161
+
162
+ def []=(key, value)
163
+ begin
164
+ self.noncapturing.config(key, value)
165
+ rescue MiniGit::GitError
166
+ nil
167
+ end
168
+ end
169
+
144
170
  private
145
171
 
146
172
  def with_git_env
@@ -1,3 +1,3 @@
1
1
  class MiniGit
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_development_dependency 'wrong', '>= 0.7.0'
21
21
  gem.add_development_dependency 'rake'
22
- gem.add_development_dependency 'minitest'
22
+ gem.add_development_dependency 'minitest', '~> 5.0.0'
23
23
  gem.add_development_dependency 'mocha'
24
24
  gem.add_development_dependency 'simplecov'
25
25
  end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe MiniGit do
4
+ let(:git) { MiniGit::new }
5
+
6
+ describe '#[]' do
7
+ it 'returns nil if the passed in attribute has no value' do
8
+ MiniGit::Capturing.any_instance.
9
+ expects(:system).with('git', 'config', 'foo.bar').
10
+ at_least_once.
11
+ raises(MiniGit::GitError)
12
+ assert { git['foo.bar'] == nil }
13
+ end
14
+
15
+ it 'returns a stripped configuration value if it exists' do
16
+ MiniGit::Capturing.any_instance.
17
+ expects(:system).with('git', 'config', 'foo.baz').
18
+ at_least_once.
19
+ returns("whatever\n")
20
+ assert { git['foo.baz'] == "whatever" }
21
+ end
22
+ end
23
+
24
+ describe '.[]' do
25
+ it 'returns nil if the passed in attribute has no value for class instance' do
26
+ MiniGit::Capturing.any_instance.
27
+ expects(:system).with('git', 'config', 'foo.bar').
28
+ at_least_once.
29
+ raises(MiniGit::GitError)
30
+ assert { MiniGit['foo.bar'] == nil }
31
+ end
32
+
33
+ it 'returns a stripped configuration value if it exists for class instance' do
34
+ MiniGit::Capturing.any_instance.
35
+ expects(:system).with('git', 'config', 'foo.baz').
36
+ at_least_once.
37
+ returns("whatever\n")
38
+ assert { MiniGit['foo.baz'] == "whatever" }
39
+ end
40
+ end
41
+
42
+ describe '#[]=' do
43
+ it 'assigns value to a git config attribute' do
44
+ MiniGit.any_instance.
45
+ expects(:system).with('git', 'config', 'bar.baz', 'foo')
46
+ git['bar.baz'] = 'foo'
47
+ end
48
+ end
49
+
50
+ describe '.[]=' do
51
+ it 'assigns value to a git config attribute for class instance' do
52
+ MiniGit.any_instance.
53
+ expects(:system).with('git', 'config', 'bar.baz', 'foo')
54
+ MiniGit['bar.baz'] = 'foo'
55
+ end
56
+ end
57
+ end
@@ -106,6 +106,7 @@ describe MiniGit do
106
106
  it 'raises an error if command fails' do
107
107
  git.git_command = 'false'
108
108
  assert { MiniGit::GitError === rescuing { git.git(:wrong) } }
109
+ system 'true' # to reset $? to a clean value
109
110
  end
110
111
  end
111
112
 
@@ -11,17 +11,22 @@ SimpleCov.start do
11
11
  minimum_coverage 95
12
12
  end
13
13
 
14
- require 'minitest/spec'
15
14
  require 'minitest/autorun'
15
+ require 'minitest/spec'
16
16
  require 'mocha/setup'
17
17
  require 'wrong'
18
- require 'wrong/adapters/minitest'
19
18
 
20
- begin
21
- require 'minitest/ansi'
22
- rescue LoadError # that's fine, we'll live without it
23
- else
24
- MiniTest::ANSI.use! if STDOUT.tty?
19
+ class MiniGit
20
+ module Spec
21
+ module WrongHelper
22
+ include Wrong::Assert
23
+ include Wrong::Helpers
24
+
25
+ def increment_assertion_count
26
+ self.assertions += 1
27
+ end
28
+ end
29
+ end
25
30
  end
26
31
 
27
32
  require 'minigit'
@@ -34,6 +39,8 @@ class MiniGit
34
39
  end
35
40
 
36
41
  class MiniTest::Spec
42
+ include MiniGit::Spec::WrongHelper
43
+
37
44
  attr_reader :tmp_path
38
45
  before do
39
46
  @tmp_path = Pathname.new(__FILE__).dirname.dirname.join('tmp').expand_path
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minigit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
5
- prerelease:
4
+ version: 0.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Maciej Pasternacki
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-03-03 00:00:00.000000000 Z
11
+ date: 2013-07-18 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: wrong
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ! '>='
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ! '>='
44
39
  - !ruby/object:Gem::Version
@@ -46,23 +41,20 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: minitest
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: 5.0.0
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: 5.0.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: mocha
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -78,7 +69,6 @@ dependencies:
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: simplecov
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - ! '>='
84
74
  - !ruby/object:Gem::Version
@@ -86,7 +76,6 @@ dependencies:
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - ! '>='
92
81
  - !ruby/object:Gem::Version
@@ -100,6 +89,8 @@ extra_rdoc_files: []
100
89
  files:
101
90
  - .gitignore
102
91
  - .travis.yml
92
+ - CHANGELOG.md
93
+ - CONTRIBUTING.md
103
94
  - Gemfile
104
95
  - LICENSE.txt
105
96
  - README.md
@@ -108,6 +99,7 @@ files:
108
99
  - lib/minigit/version.rb
109
100
  - minigit.gemspec
110
101
  - spec/minigit_git_dir_spec.rb
102
+ - spec/minigit_hash_access_spec.rb
111
103
  - spec/minigit_spec.rb
112
104
  - spec/minigit_spec.rb~
113
105
  - spec/minigit_switches_for_spec.rb
@@ -115,36 +107,30 @@ files:
115
107
  - spec/spec_helper.rb~
116
108
  homepage: https://github.com/3ofcoins/minigit
117
109
  licenses: []
110
+ metadata: {}
118
111
  post_install_message:
119
112
  rdoc_options: []
120
113
  require_paths:
121
114
  - lib
122
115
  required_ruby_version: !ruby/object:Gem::Requirement
123
- none: false
124
116
  requirements:
125
117
  - - ! '>='
126
118
  - !ruby/object:Gem::Version
127
119
  version: '0'
128
- segments:
129
- - 0
130
- hash: 360386013991135033
131
120
  required_rubygems_version: !ruby/object:Gem::Requirement
132
- none: false
133
121
  requirements:
134
122
  - - ! '>='
135
123
  - !ruby/object:Gem::Version
136
124
  version: '0'
137
- segments:
138
- - 0
139
- hash: 360386013991135033
140
125
  requirements: []
141
126
  rubyforge_project:
142
- rubygems_version: 1.8.25
127
+ rubygems_version: 2.0.5
143
128
  signing_key:
144
- specification_version: 3
129
+ specification_version: 4
145
130
  summary: A simple Ruby interface for Git
146
131
  test_files:
147
132
  - spec/minigit_git_dir_spec.rb
133
+ - spec/minigit_hash_access_spec.rb
148
134
  - spec/minigit_spec.rb
149
135
  - spec/minigit_spec.rb~
150
136
  - spec/minigit_switches_for_spec.rb