We're playing with RC3 and the git support and have run into an interesting bug we don't quite understand regarding submodules.
As best as we can tell, Drush dl creates a temp directory (drush_tempdir) which is used as base_project_path passed in as part of $request ($project in the get_drupalorg.inc code). For regular git use, that would be fine, but the submodule function verifies that the base path is a git repository, which it doesn't seem would ever be the case for a temp directory returned by drush_tempdir.
On the face of it, it almost seems like Git submodules should sidestep the temp directory process altogether, since outside of drush your 'git submodule add' command would normally be run from within your git repo.
Are we missing something basic here?
Executing: mkdir '/tmp/drush_tmp_1292450108' [notice]
Downloading project token to /tmp/drush_tmp_1292450108 ... [notice]
Downloading project token ... [notice]
Executing: cd '/tmp/drush_tmp_1292450108' ; git rev-parse --git-dir [notice]
Unable to create token as a git submodule: /tmp/drush_tmp_1292450108
is not in a Git repository. [error]
Error downloading token [notice]
An error occurred at function : drush_pm_download [error]
Command dispatch complete [notice]
Comment | File | Size | Author |
---|---|---|---|
#12 | drush-999480.patch | 5.74 KB | jonhattan |
#7 | drush-999480.patch | 11.15 KB | jonhattan |
#1 | drush_git_submodule.patch | 3.48 KB | 7sudos |
Comments
Comment #1
7sudos CreditAttribution: 7sudos commentedHere's an initial attempt to fix the problem that we worked up after our pinging around on it....
Comment #2
jonhattanA limitation here is that pm-download invokes a hook after downloading the project to alter the final install location. See:
I'll try to work something out.
Comment #3
logickal CreditAttribution: logickal commentedCool. Looking at that function, I'm a little stumped as to how drush_pm_download_destination_alter would need to work for Submodules. At the moment, it looks like it's purely for handling moving drush commands to an appropriate place, but I'm guessing there's some future use cases as well. If one was attempting to pull a drush related project as a submodule, you will have had to have pulled down drush as a git repo as well. Is this a sticky situation, or am I overthinking things?
Comment #4
greg.1.anderson CreditAttribution: greg.1.anderson commentedI don't think there's an issue, but I'm a little confused by #3. By submodule do you mean an extension (module or theme) that is in a subfolder of a project? drush_pm_download_destination_alter only works for projects; the extensions inside move with the project.
Projects that contain only drush commands are automatically moved to ~/.drush. I think this should work okay with git even if drush was not pulled down via git, but maybe I'm missing something.
Comment #5
logickal CreditAttribution: logickal commentedRight, we should probably clear up the terminology. So, the submodules we're referring to in this issue are a specific type of git repository - from the git documentation:
So, the submodules here should not be confused with the Drupal concept of submodules, as you mention.
The overall issue is that git submodues MUST be cloned into a location that is already under git's version control. One of the reasons we subverted some of this functionality in our patch (I'm one of the three people with 7sudos, by the way) is because it seems that the concept of pulling via git into an arbitrary temp directory (that may not be a part of the git repo) won't work in many cases when you're dealing with git submodules, which MUST be cloned directly into an existing repo.
Thanks to everyone - does this help to clear up the issue a bit?
Comment #6
moshe weitzman CreditAttribution: moshe weitzman commentedThanks for the clarification about git submodules.
jonhattan is just saying that the proposed code does not take into account a destination_alter hook which usually fires later. once he implements that, this looks committable to me.
Comment #7
jonhattanI have to say eureka!.
is equivalent to:
The proposed workflow is to not consider --gitsubmodule a different way to install projects but an extra step after the project has been installed. It does it by implementing hook_drush_pm_post_download().
ps. I found this post of interest to get introduced to git submodules: http://chrisjean.com/2009/04/20/git-submodules-adding-using-removing-and...
Comment #8
jonhattanComment #9
moshe weitzman CreditAttribution: moshe weitzman commentedI didn’t test this, but the code looks great. I wonder if we should expand hook_drush_pm_post_download() so that we let version control engines participate.
We can commit this as is IMO.
Comment #10
jonhattanfor vc engines: this is part of drush_pm_download():
committed. @7sudos reopen if you get any problem.
Comment #11
moshe weitzman CreditAttribution: moshe weitzman commentedOops, I meant "I wonder if we should expand hook_drush_pm_post_download() so that we let *package handlers* participate. " The gosal is to move git specific code out of pm_drush_pm_post_download and into the git_drupalorg file.
Comment #12
jonhattansomething like package_handler_post_install()? I've used post_install instead of post_download to be in concordance with package_handler_install_project(),.. perhaps both should change to _download
Comment #13
moshe weitzman CreditAttribution: moshe weitzman commentedYes, thats the idea. I do think we should rename both to post_download.
Comment #14
jonhattandone as of #12. now package-handlers interface is
Comment #15
logickal CreditAttribution: logickal commentedOn behalf of myself and the rest of 7suods, thanks a million, guys. I'm going to pull and check it out now!