Created
May 19, 2011 04:07
-
-
Save tigris/980166 to your computer and use it in GitHub Desktop.
Bundler issues from cron due to Dir.chdir(path) not "sticking" through a %x{} shell call
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- /usr/lib/ruby/gems/1.9.1/gems/bundler-1.0.13/lib/bundler/source.rb 2011-05-19 13:55:32.560582929 +1000 | |
+++ source.rb 2011-05-19 13:56:23.779939014 +1000 | |
@@ -619,7 +619,7 @@ | |
return if has_revision_cached? | |
Bundler.ui.info "Updating #{uri}" | |
in_cache do | |
- git %|fetch --force --quiet --tags "#{uri}" "refs/heads/*:refs/heads/*"| | |
+ git %|--git-dir "#{Dir.pwd}" fetch --force --quiet --tags "#{uri}" "refs/heads/*:refs/heads/*"| | |
end | |
else | |
Bundler.ui.info "Fetching #{uri}" | |
@@ -634,14 +634,13 @@ | |
FileUtils.rm_rf(path) | |
git %|clone --no-checkout "#{cache_path}" "#{path}"| | |
end | |
- Dir.chdir(path) do | |
- git %|fetch --force --quiet --tags "#{cache_path}"| | |
- git "reset --hard #{revision}" | |
+ dir_opts = %|--git-dir "#{path}/.git" --work-tree "#{path}"| | |
+ git %|#{dir_opts} fetch --force --quiet --tags "#{cache_path}"| | |
+ git "#{dir_opts} reset --hard #{revision}" | |
- if @submodules | |
- git "submodule init" | |
- git "submodule update" | |
- end | |
+ if @submodules | |
+ git "#{dir_opts} submodule init" | |
+ git "#{dir_opts} submodule update" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Forgot to note, the places I am setting --git-dir and --work-tree, need to escape the directory before passing to shell, just not sure the best way to escape it.