octopolo 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Mzk1M2QwM2YzMDU2YjYzMDc4YjlhMTQyZTVlMWM4NTA5ZDcxZjZhMQ==
4
+ YjBkOWNlNGY5ZGYyYThmNjE4NjA5YzAyNDhmOGViOTVhMmI0ZTJkNw==
5
5
  data.tar.gz: !binary |-
6
- NmQ5ZjZlNjNlM2QzZDIxOWI3ZTE0N2U2MzBjZTk5NWI0ZDQ2ZDM2NQ==
6
+ ZGUzMGFmZmM2ZGQxNDk5YjhhNjFlMWY3M2IxOWM3YmRiMWZjMTA2MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGZhM2UyYTdhYzQ4MzNlYTE3MGFhMWFmZDRkNjg3ZTZiZjY3OTA3M2U1ODQy
10
- ZTRlMWFiOWVkZGNmMWFlZGIwZWNkZGQ0MjBhNDBiZDhjNTA4Nzg0YWQ2Mjlh
11
- YWI5ZjBiZDRhMTdkOWI5ZGM3NjBkNmI5YThiODkyNTQ2NTUwZWQ=
9
+ NDcwNjNkYTQ3OWI2OTRjNTE3YWRkMWEyOTRlMTJiZDg0OGRiYWJkMGFhZGZh
10
+ NGMxOTM0MjU5ZTAxZGE1NzllNmIyODQ2ODdlYmUwODQzNTU0OTYzZDQwY2Nm
11
+ YzQyYWJlNDg5OWM3OTllNjNkZTUwYzUzNjdlYWRiMzdkNjk5YmY=
12
12
  data.tar.gz: !binary |-
13
- MGRjZjkxZWJhNzQ1MzlmZjQ0MTQ4MWYxOGQzMjI2Mzk3ZWMyMmFhNGViMDI3
14
- M2FlOTk2YTEzYTE2NGE0YzAxNDI0ODVkY2U3MDVkNDM0NWIzZmJiOWM1ZDUz
15
- NzYyZDU5ZWRjMjFhM2NlN2JhNjkxNGVmZjJmYzA5OWM2NzhkOGE=
13
+ OThiMTI3NjcyZmVjMDI5OWJlMTZlZTVkMTA1Njk1ODZiZmU4NTk0Zjc5YWRh
14
+ OGU2NmM4MmEzOGMzYzQ5Y2RhYThlN2U5Y2Q5Mjk1OGM3MTJmMjFjNzhiZGI3
15
+ OTAzYmE5YjVkMWY2MjJlZmU0MTU3MzE5MWE4MzY3MGEyYmU5Zjg=
data/CHANGELOG.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ #### v0.3.6
2
+ * Some git commands are expected to return non-zero
3
+
4
+ > Brian Bergstrom: : https://github.com/sportngin/octopolo/pull/51
5
+
1
6
  #### v0.3.5
2
7
  * Dated branch delete flag patch
3
8
 
data/lib/octopolo/cli.rb CHANGED
@@ -8,6 +8,7 @@ module Octopolo
8
8
  #
9
9
  # command - A String containing the command to perform.
10
10
  # say_command - A Boolean determining whether to display the performed command to the screen. (default: true)
11
+ # ignore_non_zero - Ignore exception for non-zero exit status of command.
11
12
  #
12
13
  # Examples
13
14
  #
@@ -20,13 +21,13 @@ module Octopolo
20
21
  # # => "Already up-to-date."
21
22
  #
22
23
  # Returns the output of the command as a String.
23
- def self.perform(command, say_command = true)
24
+ def self.perform(command, say_command = true, ignore_non_zero=false)
24
25
  # display the command
25
26
  say command if say_command
26
27
  # and then perform it
27
28
  if Open3.respond_to?(:capture3)
28
29
  output, error, status = Open3.capture3(command)
29
- raise "command=#{command}; exit_status=#{status.exitstatus}; stderr=#{error}" unless status.success?
30
+ raise "command=#{command}; exit_status=#{status.exitstatus}; stderr=#{error}" unless status.success? || ignore_non_zero
30
31
  else
31
32
  # Only necessary as long as we use 1.8.7, which doesn't have Open3.capture3
32
33
  output = `#{command}`
data/lib/octopolo/git.rb CHANGED
@@ -22,13 +22,16 @@ module Octopolo
22
22
  # Public: Perform the given Git subcommand
23
23
  #
24
24
  # subcommand - String containing the subcommand and its parameters
25
+ # options - Hash
26
+ # ignore_non_zero - Ignore exception for non-zero exit status of command.
25
27
  #
26
28
  # Example:
27
29
  #
28
30
  # > Git.perform "status"
29
31
  # # => output of `git status`
30
- def self.perform(subcommand)
31
- cli.perform "git #{subcommand}"
32
+ def self.perform(subcommand, options={})
33
+ options[:ignore_non_zero] ||= false
34
+ cli.perform("git #{subcommand}", true, options[:ignore_non_zero])
32
35
  end
33
36
 
34
37
  # Public: Perform the given Git subcommand without displaying the output
@@ -125,7 +128,7 @@ module Octopolo
125
128
  def self.merge(branch_name)
126
129
  Git.if_clean do
127
130
  Git.fetch
128
- perform "merge --no-ff origin/#{branch_name}"
131
+ perform "merge --no-ff origin/#{branch_name}", :ignore_non_zero => true
129
132
  raise MergeFailed unless Git.clean?
130
133
  Git.push
131
134
  end
@@ -233,7 +236,7 @@ module Octopolo
233
236
  # branch_name - The name of the branch to delete
234
237
  def self.delete_branch(branch_name)
235
238
  perform "push origin :#{branch_name}"
236
- perform "branch -D #{branch_name}"
239
+ perform "branch -D #{branch_name}", :ignore_non_zero => true
237
240
  end
238
241
 
239
242
  # Public: Branches which have been merged into the given branch
@@ -1,3 +1,3 @@
1
1
  module Octopolo
2
- VERSION = "0.3.5"
2
+ VERSION = "0.3.6"
3
3
  end
@@ -41,6 +41,13 @@ module Octopolo
41
41
  .to raise_error(RuntimeError, "command=#{command}; exit_status=1; stderr=kaboom")
42
42
  end
43
43
 
44
+ it "should ignore non zero return from command" do
45
+ subject.should_receive(:say).with(command)
46
+ Open3.should_receive(:capture3).with(command).and_return([result, "kaboom", status_error])
47
+ subject.should_receive(:say).with(result)
48
+ expect { subject.perform(command, true, true) }.to_not raise_error
49
+ end
50
+
44
51
  it "should not speak the command if told not to" do
45
52
  subject.should_receive(:say).with(command).never
46
53
  subject.perform(command, false)
@@ -11,7 +11,7 @@ module Octopolo
11
11
  before { Git.cli = cli }
12
12
 
13
13
  it "performs the given subcommand" do
14
- cli.should_receive(:perform).with("git #{command}")
14
+ cli.should_receive(:perform).with("git #{command}", true, false)
15
15
  Git.perform command
16
16
  end
17
17
  end
@@ -176,7 +176,7 @@ module Octopolo
176
176
  it "fetches the latest code and merges the given branch name" do
177
177
  Git.should_receive(:if_clean).and_yield
178
178
  Git.should_receive(:fetch)
179
- Git.should_receive(:perform).with("merge --no-ff origin/#{branch_name}")
179
+ Git.should_receive(:perform).with("merge --no-ff origin/#{branch_name}", :ignore_non_zero => true)
180
180
  Git.should_receive(:clean?) { true }
181
181
  Git.should_receive(:push)
182
182
 
@@ -186,7 +186,7 @@ module Octopolo
186
186
  it "does not push and raises MergeFailed if the merge failed" do
187
187
  Git.should_receive(:if_clean).and_yield
188
188
  Git.should_receive(:fetch)
189
- Git.should_receive(:perform).with("merge --no-ff origin/#{branch_name}")
189
+ Git.should_receive(:perform).with("merge --no-ff origin/#{branch_name}", :ignore_non_zero => true)
190
190
  Git.should_receive(:clean?) { false }
191
191
  Git.should_not_receive(:push)
192
192
 
@@ -434,7 +434,7 @@ module Octopolo
434
434
 
435
435
  it "leverages git-extra's delete-branch command" do
436
436
  Git.should_receive(:perform).with("push origin :#{branch_name}")
437
- Git.should_receive(:perform).with("branch -D #{branch_name}")
437
+ Git.should_receive(:perform).with("branch -D #{branch_name}", :ignore_non_zero => true)
438
438
  Git.delete_branch branch_name
439
439
  end
440
440
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: octopolo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Byrne