Permalink
Browse files

Verbosity is turned on by default unless explicitly turned off with -…

…-no-verbose or set to false in git config (pivotal.verbose).
  • Loading branch information...
1 parent bf3c713 commit 74ce45f64474a41425b4343b371b037461504645 @zdennis committed Apr 24, 2012
Showing with 38 additions and 5 deletions.
  1. +2 −2 features/accept.feature
  2. +8 −0 features/step_definitions/steps.rb
  3. +10 −3 lib/commands/base.rb
  4. +18 −0 spec/commands/base_spec.rb
View
@@ -53,7 +53,7 @@ Feature: git accept
project-id = PIVOTAL_TEST_PROJECT
"""
When I run `git-accept -k PIVOTAL_API_KEY -p PIVOTAL_TEST_PROJECT`
- Then the output should contain:
+ Then the output should contain each line:
"""
Marking Story CURRENT_CARD as accepted...
Pushing CURRENT_CARD-feature to origin
@@ -84,7 +84,7 @@ Feature: git accept
project-id = PIVOTAL_TEST_PROJECT
"""
When I run `git-accept -k PIVOTAL_API_KEY -p PIVOTAL_TEST_PROJECT`
- Then the output should contain:
+ Then the output should contain each line:
"""
Marking Story CURRENT_CARD as accepted...
Pushing CURRENT_CARD-feature to origin
@@ -22,6 +22,7 @@
| acceptance-branch = acceptance
| integration-branch = master
| project-id = PIVOTAL_TEST_PROJECT
+ | verbose = false
EOT
end
@@ -33,6 +34,7 @@
| integration-branch = whoknows
| project-id = something
| remote = origin
+ | verbose = false
EOT
end
@@ -112,3 +114,9 @@
Then /^card (CURRENT_\w+) is marked is started in Pivotal Tracker$/ do |card_id|
assert_card_is_started(card_id)
end
+
+Then /^the output should contain each line:$/ do |str|
+ str.split("\n").each do |line|
+ assert_partial_output(line, all_output)
+ end
+end
View
@@ -29,8 +29,12 @@ def put(string, newline=true)
end
def sys(cmd)
- put cmd if options[:verbose]
- system cmd #"#{cmd} > /dev/null 2>&1"
+ if options[:verbose]
+ put cmd
+ system cmd
+ else
+ system "#{cmd} > /dev/null 2>&1"
+ end
end
def get(cmd)
@@ -79,7 +83,7 @@ def full_name
def remote
options[:remote] || "origin"
end
-
+
private
def parse_gitconfig
@@ -92,6 +96,7 @@ def parse_gitconfig
only_mine = get("git config --get pivotal.only-mine").strip
append_name = get("git config --get pivotal.append-name").strip
use_ssl = get("git config --get pivotal.use-ssl").strip
+ verbose = get("git config --get pivotal.verbose").strip
options[:api_token] = token unless token == ""
options[:project_id] = id unless id == ""
@@ -102,6 +107,8 @@ def parse_gitconfig
options[:only_mine] = (only_mine != "") unless name == ""
options[:append_name] = (append_name != "")
options[:use_ssl] = (/^true$/i.match(use_ssl))
+
+ options[:verbose] = verbose == "" ? true : (/^true$/i.match(verbose))
end
def parse_argv(*args)
View
@@ -64,6 +64,24 @@
@pick = Commands::Base.new("--no-verbose").with(@input, @output)
@pick.options[:verbose].should be_false
end
+
+ it "should respect verbose from git config if it's set true (case insensitive)" do
+ Commands::Base.any_instance.stubs(:get).with("git config --get pivotal.verbose").returns("truE")
+ @pick = Commands::Base.new
+ @pick.options[:verbose].should be_true
+ end
+
+ it "should respect verbose from git config if it's set true (case insensitive)" do
+ Commands::Base.any_instance.stubs(:get).with("git config --get pivotal.verbose").returns("falSe")
+ @pick = Commands::Base.new
+ @pick.options[:verbose].should be_false
+ end
+
+ it "should be verbose by default" do
+ Commands::Base.any_instance.stubs(:get).with("git config --get pivotal.verbose").returns("")
+ @pick = Commands::Base.new
+ @pick.options[:verbose].should be_true
+ end
it "should set the integration branch with the -b option" do
@pick = Commands::Base.new("-b", "integration").with(@input, @output)

0 comments on commit 74ce45f

Please sign in to comment.