Skip to content

Commit

Permalink
Fix recursive builds overwriting already processed projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhedstrom committed Aug 16, 2013
1 parent 81f3b3c commit f65f3cb
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
6 changes: 6 additions & 0 deletions commands/make/make.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function make_drush_command() {
),
'options' => array(
'projects' => 'An array of projects generated by make_projects()',
'manifest' => 'An array of projects already being processed',
),
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
'engines' => array('release_info'),
Expand Down Expand Up @@ -212,8 +213,11 @@ function drush_make_process($directory) {
make_tmp(TRUE, $directory);
$projects = drush_get_option('projects', FALSE);

$manifest = drush_get_option('manifest', FALSE);

foreach ($projects as $project) {
if ($instance = DrushMakeProject::getInstance($project['type'], $project)) {
$instance->setManifest($manifest);
$instance->make();
}
else {
Expand Down Expand Up @@ -426,6 +430,8 @@ function make_projects($recursion, $contrib_destination, $info, $build_path, $ma
}
// Add the project to this sub-process.
$invocations[$thread]['options']['projects'][] = $project;
// Add the manifest so recursive downloads do not override projects.
$invocations[$thread]['options']['manifest'] = $projects['contrib'];
}
if (!empty($invocations)) {
// Backend options.
Expand Down
23 changes: 23 additions & 0 deletions commands/make/make.project.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ class DrushMakeProject {
*/
protected static $self = array();

/**
* Keeps track of projects being processed to prevent recursive conflicts.
*
* Simple array of machine names.
*
* @var array
*/
protected $manifest = array();

/**
* Default to overwrite to allow recursive builds to process properly.
*
Expand Down Expand Up @@ -71,6 +80,16 @@ class DrushMakeProject {
return self::$self[$type][$project['name']];
}

/**
* Set the manifest array.
*
* @param array $manifest
* An array of projects as generated by `make_projects`.
*/
public function setManifest($manifest) {
$this->manifest = array_keys($manifest);
}

/**
* Download a project.
*/
Expand Down Expand Up @@ -518,6 +537,10 @@ class DrushMakeProject {
$result = FALSE;
}
else {
// Strip out any modules that have already been processed before this.
foreach ($this->manifest as $name) {
unset($info['projects'][$name]);
}
$build_path = $this->buildPath($this->name);
make_projects(TRUE, trim($build_path, '/'), $info, $this->build_path, $this->download_location);
make_libraries(trim($build_path, '/'), $info, $this->build_path, $this->download_location);
Expand Down
13 changes: 13 additions & 0 deletions tests/makeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ function testMakeRecursion() {
$this->runMakefileTest('recursion');
}

function testMakeRecursionOverride() {
$this->runMakefileTest('recursion-override');
}

function testMakeSvn() {
// Silently skip svn test if svn is not installed.
exec('which svn', $output, $whichSvnErrorCode);
Expand Down Expand Up @@ -460,6 +464,15 @@ function getMakefile($key) {
'contrib-destination' => 'profiles/drupal_forum',
),
),
'recursion-override' => array(
'name' => 'Recursion overrides',
'makefile' => 'recursion-override.make',
'build' => TRUE,
'md5' => 'a13c3d5d416be9fa78569514844b96a2',
'options' => array(
'no-core' => NULL,
),
),
'svn' => array(
'name' => 'SVN',
'makefile' => 'svn.make',
Expand Down
9 changes: 9 additions & 0 deletions tests/makefiles/recursion-override.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
core = 7.x
api = 2

defaults[projects][subdir] = "contrib"

; Custom formatters contains the library module v1, we want v2.
projects[libraries][version] = 2.1

projects[custom_formatters][version] = 2.2

0 comments on commit f65f3cb

Please sign in to comment.