Cron issues with git source gems #1213

Closed
wants to merge 3 commits into
from

Projects

None yet

2 participants

@tigris

Use the --git-dir and --work-tree options for existing git repos rather than chdir to them. This is due to some problem with cron not properly chdir'ing.

We run a "bundle install" in our git/hook/post-merge, and "git pull" out of cron ever hour. So if you push code to github, cron will pull it out on the hour and then post-merge will run the bundle install. All non-interactive. Unforunately this barfs on gems that use git as the source. From debugging it seems that when bundler does a chdir and then invokes git, the chain is something like cron -> invoked git -> invoked bundler -> chdir'd -> invoked git. For some reason the last git doesn't see the chdir and tries to run it's git commands from ".".

The only solution I see is to not chdir for git, but instead pass git the flags it needs to know which repo to act upon. Which is the solution I have implemented here, and it fixes the problem while still working normally as well (outside of cron).

@tigris tigris Use the --git-dir and --work-tree options for existing git repos rath…
…er than chdir to them. This is due to some problem with cron not properly chdir'ing.
830e0ad
@indirect
Bundler member

What is the lowest version of git that supports this? Thanks.

@tigris

According to http://www.kernel.org/pub/software/scm/git/docs/ --work-tree came in 1.5.3.8. None of the release notes mention which version of 1.5.3 but it's listed in the man page for final 1.5.3.8. As for --git-dir, it's been around since day 1.

@indirect
Bundler member

It seems really awkward to use Dir.pwd from inside in_cache{}. Could you implement this so it actually just passes the cache directory instead?

@tigris

All done.

@indirect
Bundler member

Pulled in 45c4529, thanks!

@indirect indirect closed this Sep 18, 2011
@indirect indirect added a commit that referenced this pull request Sep 19, 2011
@indirect indirect Revert "Merge pull request #1213 from tigris/bundler"
This reverts commit 45c4529, reversing
changes made to d9dd6ed.
5d75b3f
@tigris

Was there a reason for the revert that you need me to fix?

@indirect
Bundler member

Sorry, I meant to comment, but got caught up in other stuff around the latest releases. These changes unfortunately mean that commands around git submodules completely stop working. (As far as I can tell, submodule commands actually require that you change the cwd to work at all). It would be great if you could check on that and make it work. There are some specific tests around submodule behaviour that broke when I applied your patch, so you should be able to use those to test.

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