Skip to content

Instantly share code, notes, and snippets.

@tigris
Created May 19, 2011 04:07
Show Gist options
  • Save tigris/980166 to your computer and use it in GitHub Desktop.
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
--- /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
@tigris
Copy link
Author

tigris commented May 19, 2011

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment