When drush make checks out stuff directly from Git, it'd be nice if it rewrote any .info files included in the directory tree for that particular project to define the stuff that update manager needs to know what's up. In particular, it needs to define project and version. Project is trivial. Version is more complicated. When checking out from a specific git tag or release branch, it's easy. But if you're checking out from a feature branch you're kind of doomed. And if you checkout a specific git hash, we don't necessarily know what version that corresponds to.
The current thinking on this problem from the d.o distribution packaging side of things is that if a distro maintainer is savvy enough to know how to specify a specific git hash, they'll also be savvy enough to define an appropriate version string. So, the idea is that the downloader parts would honor the 'revision' keyword in the .make file, while the .info re-writing parts would have to look for 'version.' Maybe it becomes a fatal error if you define a hash without a version.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 1371298-14.dev-version-fix.patch | 632 bytes | dww |
| #12 | 1371298-12.download-full_version-fix-for-git.patch | 1.75 KB | dww |
| #11 | 1371298-11.download-version-string-fix-for-git.patch | 2.53 KB | dww |
| #10 | 1371298-10.version-is-project-level.patch | 1.27 KB | dww |
| #9 | 1371298-9.version-is-project-level.patch | 1.08 KB | dww |
Comments
Comment #1
jhedstromThis should be done in conjunction with #1302820: Inject version info into .info file in git_drupalorg engine for tracking through *default* update report, and is blocked by #1267228: Drush Make should use Drush core's native download abilities concurrently.
Comment #2
dwwTo clarify, this is absolutely necessary when drush make is pulling from Git and run without the
--working-copyflag, since you neither have the benefit of the d.o packaging script's .info file rewriting from tarballs, not any possibility that git_deploy can work, since the Git data is destroyed before make is done. drush make itself is the only thing that can make update manager work in this case.However, moshe pointed out in IRC that *always* rewriting the .info files, even if you're doing
--working-copymight be annoying, since then you get all these superfluous git diffs in your workspace.So, we probably want a kill switch for this .info rewriting, and we should consider if that killswitch should always be triggered with
--working-copy...Comment #3
dwwBump. The issues in #1 are both done and merged into drush's master branch. I *believe* all we'd need to do for this is ensure that if a given project is configured to use the 'git' download type, that we add --gitinfofile to the options used when invoking drush pm-download concurrently. However, poking around the code, it's not obvious how to do that. ;) The patch here is just a placeholder for where I believe the check should happen, but I don't know what to do inside the if clause to actually set the option we need for this particular project's concurrent invocation. There's a lot of mojo going on with propagating options into the concurrent backend and I don't grok all of that.
Maybe this is the wrong place to be trying to define and propagate that option. Perhaps we want to do it inside make_download_git()? In fact, given make_download_git(), I don't really see how the pm download code is being used at all here. Maybe that conversion is still incomplete. In that case, seems like we just need to reuse the code to munge the .info files directly inside make_download_git()?
Anyway, it'd be nice to get this wrapped up soon so that we can allow -dev releases in distros packaged on d.o. I'm happy to work on this if I had some clear direction on where to make this happen.
Thanks,
-Derek
Comment #4
jhedstromUntil #1375270: Drush Make should use Drush core's native download abilities for git clones is done, this will have to be done in
make_download_git(). We need an option to turn this behavior off as well (if for no other reason than the md5-based git tests will all break if we don't).Comment #5
dwwGreat, thanks for the clarification. I didn't notice #1375270: Drush Make should use Drush core's native download abilities for git clones. I'll take a stab at this now and see how far I get.
Comment #6
dwwI got pulled into other things, but I came back to this and worked out the attached patch. It's a bit of a hack in some ways, but hopefully I'm making up for it by cleaning up some of the code and logic in other ways. ;) I got some pointers from Moshe on where he wanted various pieces of this code to live, so hopefully this can go in for now and all be revisited once we're really working on #1375270.
Patch summary:
- Added a new shared helper function
drush_file_append_data()to includes/filesystem.inc- Totally refactored, cleaned up, renamed, and moved package_handler_inject_info(). It now lives in commands/pm/pm.drush.inc as drush_pm_inject_info_file_metadata(). Fixed it to only generate the info metadata string once, then iterate over all the .info files using drush_file_append_data() to append that little hunk of .info metadata to each one. Also, instead of taking PM-specific opaque arrays as input and only using certain keys out of them, it now just takes 3 self-documenting parameters for its input.
- make_download_git() now tries to figure out a version string to use based on the .make contents, and uses drush_pm_inject_info_file_metadata() to inject .info data unless the --no-gitinfofile killswitch is set.
- Fixed makeTest.php to set this killswitch on the two git makefile tests that do md5 comparisons.
Some things to discuss about the option/killswitch:
A) Should it be a --no- style killswitch like the other make options, or should it be opt-in like the --gitinfofile option in pm-download?
B) How should it interact with --working-copy?
IMHO, we *must* rewrite the info files if --working-copy isn't defined (unless the user specifically tells us not to). So, since --working-copy defaults to FALSE, I think this needs to default to TRUE instead of being opt-in. And given it needs to be opt-out, seems like a --no is best. At least that was my rationale for writing it this way. ;)
Thanks
-Derek
p.s. With the patch, I'm getting:
Comment #7
moshe weitzman commentedMakes sense to me. Committed. Thanks.
Comment #8
dwwSweet, thanks!
However, I realized there's a problem here:
Actually, 'version' is a project-level attribute, not a download-level attribute. I.e. in the .make file, you say this:
Not this:
This is particularly an issue in combination with #1371306: Add validation to ensure that if a .make file includes a git hash, it also defines a branch. At least for the d.o distro packaging case, if .make authors define a 'revision' (to checkout from a specific git hash) we're requiring they define a version so we can rewrite the .info files appropriately (since a given hash might live on many branches, we don't know exactly what they're intending). However, that's just in the project data, not in the download data, so it's never getting passed to make_download_factory(). :( I'm not 100% sure what to do about this, other than perhaps inside DrushMakeProject::download(), before we call make_download_factory(), we should copy the version info (if we've got it) out of
$this->versionand put it into$this->download['version'](or something). While we're at it, that's probably a reasonable place to prepend the core version (e.g. the '7.x' part) so that the version string looks like we expect.The whole way make handles versions is a bit weird, but a more far-reaching refactoring is obviously way out of scope here.
Thoughts?
Thanks!
-Derek
Comment #9
dwwFor consideration, here's what I'm talking about. This actually works, although it makes me feel dirty inside.
Comment #10
dwwUgh. Maybe #9 isn't the right approach either. Digging into the pm case, I found related badness. See #1267228-73: Drush Make should use Drush core's native download abilities concurrently for more. But, I think #9 has the potential to break the pm case. I believe this is safer.
Comment #11
dwwNew patch based on #1267228-74: Drush Make should use Drush core's native download abilities concurrently.
Comment #12
dwwRe-rolled for #1267228-79: Drush Make should use Drush core's native download abilities concurrently
Comment #13
moshe weitzman commentedcommitted. thx.
Comment #14
dwwUgh, sorry. Clearly we need to write some tests for all of these edge cases. But, I found a problem with how we handle certain -dev versions. My regexp was too permissive and when I was looking for just 1.x I was also matching 1.x-dev since I didn't include the $ to ensure that we're hitting the end of the string. This resulted in version strings like '7.x-1.x-dev-dev' in some cases. Now fixed.
Comment #15
moshe weitzman commentedcommitted
Comment #17
chrisschaub commentedSo, I'm using the latest drush 5 with this in my make file.
When I look at the module's info file, I see
version = ""
What am I doing wrong?
Thanks.
Comment #18
chrisschaub commentedCreated a new issue, please ignore
http://drupal.org/node/1694510
Comment #19
cmalek commentedI finally, finally got this to work for dev branch projects after much wrangling and but it doesn't work the way I would have expected. You have to do this:
Set
projects[$projectname][download][full_version]:then run
drush makewith the--working-copyflag:Without the
--working-copyflag, the version will never be filled in because the.gitdirectory in the cloned module repository has been purged bymake_download_git()by the timedrush_pm_git_drupalorg_compute_rebuild_version()is run to generate the version number. Since the first thing that function does is rungit describe tags(which fails), it aborts without doing anything and version gets set to the empty string.Is this expected? I would rather not to have to run with the
--working-copyflag because I don't want working copies. I have to manually purge the.gitdirectories after drush make completes.Comment #20
jhedstromThat should be fixed in drush 5.8. It was a regression: #1693452: Drush make should be on the same page as drupalorg for .info file rewrites.
Comment #21
cmalek commentedAh, thanks jhedstrom. I have 5.7. I'll update.