Recursive Drush make, working with different git branches
This is a great question! I maintain both Aegir and Drush Make, but I'm not certain that I have a really good answer for you.


I think that you're suggestion in (1) is probably the best bet at
the moment. It has the virtue of already working, as you've
mentioned. The issue with accidentally merging these [branch]
attributes is still valid though. The solution though, lies not in
Drush Make, but in Git!

Check out this article. It describes using Git attributes,
along with a custom (null) Git merge driver. To summarize, each
developer would have to run the following:

git config --global merge.ours.driver true


This basically means that when an item is flagged to use the
'ours' merge driver, it'll just call /bin/true, hence my earlier
reference to it being a null operation.

But, how do you flag your makefiles to use this driver? That's where
Git attributes come into play. Create a .gitattributes file at the root of your repo (i.e., along side .gitignore). Then add the
following line:

build-SITENAME.make merge=ours


You'll probably want to do the same for your feature repos as well.
As for solutions leveraging Drush Make, I don't know that there's a
solid solution.

A few years back, I experimented with using overrides trying to do
something similar, as described in the Drush Make
documentation. The basic idea is that you can change (override)
attributes from included makefiles.

However, in the case of recursive makefiles, they are built
separately, instead of being merged into the parent makefile prior
to build. As a result, there's no opportunity to override their
attributes. This may have changed in the time since I tested it, but
I think the underlying mechanics remain largely the same, and so
it's unlikely to work.

Setting a default in a parent makefile would be a nice way to
accomplish something like this too. I haven't tested this, but
again, I'm pretty sure the default wouldn't apply to the recursively
built makefile.

Instead, an option would be to build your parent makefile without
recursion, but rather including the feature makefiles directly. You
can now include makefiles directly from within a Git repo
(using the new YAML syntax):

includes:
  # A file from a git repository.
  makefile: "example_dir/example.make"
  download:
    type: "git"
    url: "git@github.com:organisation/repository.git"
    branch: "master"


You'd either want to call drush make with the --no-recursion
option, or specify it in your makefiles:

--no-recursion                   Do not recurse into the makefiles of any
                                 downloaded projects; you can also set 
                                 [do_recursion] = 0 on a
                                 per-project basis in the makefile.



I'm sure there are other options available, but those are the ones that I think would least impact your existing workflows. I'd be very curious to see other suggestions.

There is a feature request to allow the use of variables in .make files, which might address such a use-case more directly, if it were implemented. Perhaps we could look for such variables in options passed on the command line, or in environment variables.

That said, in the long run, I believe that Drush Make will be supplanted entirely by Composer, so it might be more fruitful to explore in that direction, if the suggestions above don't work out.