Permalink
Browse files

Fixed tests broken by ec1677a

 * project_path initialization in Config
   take global (cmdline) or use self as default
  • Loading branch information...
1 parent a76eb5c commit 3e059632cb15e4038c999f4993d30ba7dc235efd @antono antono committed with Feb 21, 2010
Showing with 15 additions and 16 deletions.
  1. +15 −16 lib/cijoe/config.rb
View
@@ -5,40 +5,39 @@ def self.method_missing(command, *args)
end
def initialize(command, parent = nil)
- @command = command
- @parent = parent
+ @command = command
+ @parent = parent
+ @project_path = $project_path || File.join(File.dirname(__FILE__), '../../')
end
def method_missing(command, *args)
Config.new(command, self)
end
def to_s
- Dir.chdir($project_path) do
- git_command = "git config #{config_string}"
- result = `#{git_command} 2>&1`.chomp
- process_status = $?
-
- if successful_command?(process_status) || config_command_with_empty_value?(result,process_status)
- return result
- else
- raise "Error calling git config, is a recent version of git installed? Command: #{git_command}, Error: #{result}"
- end
+ git_command = "cd #{@project_path} && git config #{config_string}"
+ result = `#{git_command} 2>&1`.chomp
+ process_status = $?
+
+ if successful_command?(process_status) || config_command_with_empty_value?(result,process_status)
+ return result
+ else
+ raise "Error calling git config, is a recent version of git installed? Command: #{git_command}, Error: #{result}"
end
end
def config_string
@parent ? "#{@parent.config_string}.#{@command}" : @command
end
-
+
private
-
+
def successful_command?(process_status)
process_status.exitstatus.to_i == 0
end
-
+
def config_command_with_empty_value?(result, process_status)
process_status.exitstatus.to_i == 1 && result.empty?
- end
+ end
end
end

0 comments on commit 3e05963

Please sign in to comment.