Skip to content

Commit

Permalink
Backport of drush-ops#1063 for the 6.x branch
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatias committed Jan 5, 2015
1 parent 17d744a commit 127a9dc
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 1 deletion.
13 changes: 13 additions & 0 deletions commands/make/make.utilities.inc
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ function make_parse_info_file($makefile, $parsed = TRUE, $makefile_options = arr
make_error('BUILD_ERROR', dt("Include file missing: !include", array('!include' => $include)));
}
}
elseif (!empty($include) && is_array($include)) {
if ($include['download']['type'] = 'git') {
$tmp_dir = make_tmp();
make_download_git($include['makefile'], $include['download']['type'], $include['download'], $tmp_dir);
$makefile = $tmp_dir . '/' . $include['makefile'];
if (file_exists($makefile) && $file = make_parse_info_file($makefile, FALSE)) {
$includes[] = $file;
}
else {
make_error('BUILD_ERROR', dt("Include file missing: !include", array('!include' => $makefile)));
}
}
}
}
}
$includes[] = $data;
Expand Down
6 changes: 5 additions & 1 deletion docs/make.txt
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ projects. Additionally, they may specify a destination:
### Includes

An array of makefiles to include. Each include may be a local relative path
to the includer makefile directory or a direct URL to the makefile. Includes
to the include makefile directory or a direct URL to the makefile, or from a git repository. Includes
are appended in order with the source makefile appended last, allowing latter
makefiles to override the keys/values of former makefiles.

Expand All @@ -286,6 +286,10 @@ makefiles to override the keys/values of former makefiles.
includes[example] = "example.make"
includes[example_relative] = "../example_relative/example_relative.make"
includes[remote] = "http://www.example.com/remote.make"
includes[example_git][makefile] = 'example_dir/example.make'
includes[example_git][download][type] = "git"
includes[example_git][download][url] = "git@github.com:organisation/repository.git"
includes[example_git][download][branch] = "master"

### Defaults

Expand Down
23 changes: 23 additions & 0 deletions tests/makeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,23 @@ function testMakeInclude() {
$this->runMakefileTest('include');
}

/**
* Test git support on includes directive.
*/
function testMakeIncludesGit() {
$config = $this->getMakefile('includes-git');
$options = array();
$makefile = $this->makefile_path . DIRECTORY_SEPARATOR . $config['makefile'];
$this->drush('make', array($makefile, UNISH_SANDBOX . '/test-build'), $options);

// Verify that core and example main module were downloaded.
$this->assertFileExists(UNISH_SANDBOX . '/test-build/README.txt');
$this->assertFileExists(UNISH_SANDBOX . '/test-build/sites/all/modules/contrib/apachesolr/README.txt');

// Verify that module included in sub platform was downloaded.
$this->assertFileExists(UNISH_SANDBOX . '/test-build/sites/all/modules/contrib/jquery_update/README.txt');
}

function testMakeRecursion() {
$this->runMakefileTest('recursion');
}
Expand Down Expand Up @@ -454,6 +471,12 @@ function getMakefile($key) {
'md5' => 'e2e230ec5eccaf5618050559ab11510d',
'options' => array(),
),
'includes-git' => array(
'name' => 'Including makefiles from remote repositories',
'makefile' => 'includes-main.make',
'build' => TRUE,
'options' => array(),
),
'recursion' => array(
'name' => 'Recursion',
'makefile' => 'recursion.make',
Expand Down
14 changes: 14 additions & 0 deletions tests/makefiles/includes-main.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
core = 7.x
api = 2

; Main makefile containing drupal core
includes[platform][makefile] = 'tests/makefiles/includes-platform.make'
includes[platform][download][type] = "git"
includes[platform][download][url] = "https://github.com/pmatias/drush.git"
includes[platform][download][branch] = "includes-git-support"

; Sub platform makefile
includes[subplatform][makefile] = 'tests/makefiles/includes-sub-platform.make'
includes[subplatform][download][type] = "git"
includes[subplatform][download][url] = "https://github.com/pmatias/drush.git"
includes[subplatform][download][branch] = "includes-git-support"
10 changes: 10 additions & 0 deletions tests/makefiles/includes-platform.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
api = 2
core = 7.x

; Drupal core
projects[drupal][type] = "core"
projects[drupal][version] = 7.34

; Contrib modules
projects[apachesolr][subdir] = "contrib"
projects[apachesolr][version] = "1.6"
6 changes: 6 additions & 0 deletions tests/makefiles/includes-sub-platform.make
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
api = 2
core = 7.x

; Contrib modules
projects[jquery_update][version] = "2.4"
projects[jquery_update][subdir] = "contrib"

0 comments on commit 127a9dc

Please sign in to comment.