Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cherry-picked: Fix a very annoying bug that was breaking HTTP basic a…

…uth...

  - The load order was such that the config class was being loaded
    before the project_path was being chdir'ed to.  This meant the first
    time the http auth user/pass was being retrieved (via `git config`)
    it was being done in the current dir, instead of the project dir --
    and the current dir was often not a git repo.

    So that meant that the http user/pass was empty strings the first
    time, which was the only time the server would check it - so http auth
    was effectively never working.  At least for me.

    Not sure how this worked for anyone before -- maybe everyone who has used
    http auth starts cijoe from within the repo dir?

    Anyways, this is a fairly ugly hack to ensure that the git commands in Config
    are always run in the context of the project path.
  • Loading branch information...
commit f8f85ab0f39422be07ce0e6fea205e6089dbd6c4 1 parent e021fc4
@rsanheim rsanheim authored defunkt committed
Showing with 14 additions and 9 deletions.
  1. +5 −2 bin/cijoe
  2. +9 −7 lib/cijoe/config.rb
View
7 bin/cijoe
@@ -1,7 +1,6 @@
#!/usr/bin/env ruby
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
-require 'cijoe'
require 'choice'
Choice.options do
@@ -46,4 +45,8 @@ Choice.options do
end
options = Choice.choices
-CIJoe::Server.start(options[:host], options[:port], Choice.rest[0])
+$project_path = File.expand_path(Choice.rest[0])
+
+require 'cijoe'
+
+CIJoe::Server.start(options[:host], options[:port], $project_path)
View
16 lib/cijoe/config.rb
@@ -14,14 +14,16 @@ def method_missing(command, *args)
end
def to_s
- git_command = "git config #{config_string}"
- result = `#{git_command} 2>&1`.chomp
- process_status = $?
+ 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}"
+ 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
end
Please sign in to comment.
Something went wrong with that request. Please try again.