The second example for dog-dl is as follows:

      'drush dog-dl https://github.com/kete/tiny_mce.git sites/all/libraries/tiny_mce' =>
        'Initialize tiny_mce from github in sits/all/libraries'

I really like the possibility to be able to add external libraries or drupal projects from other repositories.
Unfortunately, drush pm-download doesn't support this at the moment.
A great solution would be to have one shared package handler for drush pm, drush dog and drush make that supports all of their options.
In the mean time, I started on a dog-dl implementation that is independent (though based on) of pm-download. If you're interested, I'm happy to share the code after running some more tests. Probably after Easter.

Comments

ChrisBryant’s picture

I'd like to know more about this as well and am happy to help with testing.

Anonymous’s picture

Looks like Sam (sdboyer) is working on this in the custom-dl branch.

Anonymous’s picture

For anyone interested, I include the dog-dl code I made for myself.

I hope it can be useful for the dog-dl development

It supports the d.o. repository,
example: drush dog-dl --branch=devel libraries
local git repositories:
drush dog-dl --branch=devel /home/git/drupal/my_module.git sites/all/modules/my_module
and non-d.o. remote repositories
drush dog-dl --branch=devel https://github.com/kete/tiny_mce.git sites/all/libraries/tiny_mce

Specifying a local branch is required for this code

function drush_dog_dl($project = '', $target = '') {
  // First ensure we have a clean working copy
  $output = _dog_git_invoke('status --porcelain', DRUPAL_ROOT);
  if ($output) {
    return drush_set_error('DRUSH_DOG_DIRTY_TREE', dt("You have uncommitted changes in your working copy; dog-dl requires a clean working copy to run:\n!changes", array('!changes'=>$output)));
  }

  if (empty($project)) {
    return drush_set_error('DRUSH_DOG_PROJECT_MISSING', dt('A project must be specified.'));
  }

  // If the project doesn't contain a slash or backslash character
  // assume it's a drupal project
  if (strpos($project, '/') === FALSE && strpos($project, '\\') === FALSE) {
    $version = pm_parse_project_version(array($project));
    $version = reset($version);
    $xml = _drush_pm_get_release_history_xml($version);
    switch($xml->terms->term[0]->value) {
      case 'Modules':
        $contrib_type = 'modules';
        break;
      case 'Themes':
        $contrib_type = 'themes';
        break;
      default:
        drush_log('Unknown project type', 'error');
    }
    $release = pm_parse_release($version, $xml);
    $short_name = $xml->short_name;
    $upstream_ref = $release['tag'];
    if (isset($release['version_extra']) &&
    $release['version_extra'] == 'dev') {
      // branch tags need the 'upstream/' prefix;
      $upstream_ref = 'upstream/' . $upstream_ref;
    }
    $upstream = 'git://git.drupal.org/project/' . $short_name . '.git';
    if (empty($target)) {
      $target = 'sites/all/' . $contrib_type . '/' . $short_name;
    }
  }
  else {
    $upstream_ref = drush_get_option('upstream-ref', 'HEAD');
    $upstream = $project;
    if (empty($target)) {
      return drush_set_error('DRUSH_DOG_TARGET MISSING', dt('A target must be specified for non drupal projects.'));
    }
  }
  // Check for and resolve a relative target path
  if (substr($target, 0, 1) != '/' && substr($target, 1, 2) != ':\\') {
    $target = DRUPAL_ROOT . '/' . $target;
  }

  if (file_exists($target)) {
    return drush_set_error('DRUSH_DOG_TARGET_EXISTS', dt('Target directory !target already exists.', array('!target'=>$target)));
  }

  try {
    $remoteinfo = _dog_git_invoke('ls-remote ' . drush_escapeshellarg($upstream) . ' 7.0');
  }
  catch (Exception $e) {
    return drush_set_error('DRUSH_DOG_INVALID_UPSTREAM', dt("Upstream URI '%upstream' is not a Git repository.", array('%upstream' => $upstream)));
  }
  
  // @todo Add option for repository validation?
  //if (strpos($remoteinfo, '497914920385b7016ac9c9367e0198530787adf2') !== 0) {
  //  drush_log("Upstream URI '$upstream' is not a valid Drupal core repository.", 'error');
  //  return bad_dog();
  //}

  // Build the base clone command.
  $cmd = 'clone -q -o upstream --no-hardlinks ';

  // Use a refcache if drush has one specified
  if ($refcache = drush_get_option('git_reference_cache')) {
    $cmd .= "--reference $refcache ";
  }

  // add the clone uri and target dir
  $cmd .= escapeshellarg($upstream);

  // add the target output dir
  if (!empty($target)) {
    $cmd .= ' ' . escapeshellarg($target);
  }

  drush_log("Cloning '$upstream' into '$target'.", 'info');

  try {
    // Do the clone
    _dog_git_invoke($cmd);
  }
  catch (Exception $e) {
    return drush_set_error('DRUSH_DOG_GIT_INVOCATION_ERROR', dt("Clone of upstream repository failed."));
  }

  if (!empty($short_name)) {
    $proj_name = $short_name . '-' . $release['tag'];
  }
  else {
    $proj_name = $upstream;
  }

  drush_log("Successfully installed project $proj_name in $target.", 'success');

  // Create the appropriate local branch based on the requested start point
  $localbranch = drush_get_option('branch', 'master');

  $old = trim(_dog_git_invoke('symbolic-ref HEAD | cut -c 12-', $target));

  _dog_git_invoke('checkout -b ' . escapeshellarg($localbranch) . ' ' . escapeshellarg($upstream_ref), $target);
  _dog_git_invoke('branch -D ' . $old, $target);

  // Set the collab uri
  $collab = drush_get_option('collab', $upstream);
  _dog_git_invoke('remote add collab ' . escapeshellarg($collab), $target);

  // Add the submodule if it's in a subdirectory of DRUPAL_ROOT
  if (substr($target, 0, strlen(DRUPAL_ROOT)) == DRUPAL_ROOT) {
    $target_relative = substr($target, strlen(DRUPAL_ROOT) + 1);
    $cmd = 'submodule add ';
    $cmd .= escapeshellarg($upstream) . ' ';
    $cmd .= escapeshellarg($target_relative);
    _dog_git_invoke($cmd, DRUPAL_ROOT);

    // Add and commit .gitmodules and the new project
    $new_files = '.gitmodules ' . $target_relative . ' ' . dirname($target_relative);
    _dog_git_invoke('add -- ' . $new_files, DRUPAL_ROOT);
    _dog_git_invoke('commit -m "Add project ' . $proj_name . '" -o -- ' . $new_files, DRUPAL_ROOT);
  }
}