Skip to content

Commit

Permalink
Add git commit when we print our version of Drush (#2360).
Browse files Browse the repository at this point in the history
Formally deprecate the constants that describe Drush version.
  • Loading branch information
weitzman committed Sep 25, 2016
1 parent 6d60965 commit f503102
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions commands/core/archive.drush.inc
Expand Up @@ -21,7 +21,7 @@ function archive_drush_command() {
'destination' => 'The full path and filename in which the archive should be stored. If omitted, it will be saved to the drush-backups directory and a filename will be generated.',
'overwrite' => 'Do not fail if the destination file exists; overwrite it instead. Default is --no-overwrite.',
'generator' => 'The generator name to store in the MANIFEST file. The default is "Drush archive-dump".',
'generatorversion' => 'The generator version number to store in the MANIFEST file. The default is ' . DRUSH_VERSION . '.',
'generatorversion' => 'The generator version number to store in the MANIFEST file. The default is ' . Drush::getMajorVersion() . '.',
'pipe' => 'Only print the destination of the archive. Useful for scripts that don\'t pass --destination.',
'preserve-symlinks' => 'Preserve symbolic links.',
'no-core' => 'Exclude Drupal core, so the backup only contains the site specific stuff.',
Expand Down Expand Up @@ -232,7 +232,7 @@ function drush_archive_dump($sites_subdirs = '@self') {
'datestamp' => time(),
'formatversion' => '1.0',
'generator' => drush_get_option('generator', 'Drush archive-dump'),
'generatorversion' => drush_get_option('generatorversion', DRUSH_VERSION),
'generatorversion' => drush_get_option('generatorversion', Drush::getMajorVersion()),
'description' => drush_get_option('description', ''),
'tags' => drush_get_option('tags', ''),
'archiveformat' => ($include_platform ? 'platform' : 'site'),
Expand Down
5 changes: 3 additions & 2 deletions commands/core/core.drush.inc
Expand Up @@ -6,6 +6,7 @@
*/

use Drush\Log\LogLevel;
use SebastianBergmann\Version;

/**
* Implementation of hook_drush_help().
Expand Down Expand Up @@ -610,7 +611,7 @@ function _core_site_status_table($project = '') {
$status_table['php-conf'] = $php_ini_files;
}
$status_table['drush-script'] = DRUSH_COMMAND;
$status_table['drush-version'] = DRUSH_VERSION;
$status_table['drush-version'] = Drush::getVersion();
$status_table['drush-temp'] = drush_find_tmp();
$status_table['drush-conf'] = drush_flatten_array(drush_get_context_options('context-path', ''));
$alias_files = _drush_sitealias_find_alias_files();
Expand Down Expand Up @@ -1280,7 +1281,7 @@ function drush_core_drupal_directory($target = 'root') {
* Called for `drush version` or `drush --version`
*/
function drush_core_version() {
return DRUSH_VERSION;
return Drush::getVersion();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/cache.inc
Expand Up @@ -197,5 +197,5 @@ function drush_get_cid($prefix, $contexts = array(), $params = array()) {
$cid[] = $param;
}

return DRUSH_VERSION . '-' . $prefix . '-' . md5(implode("", $cid));
return Drush::getVersion() . '-' . $prefix . '-' . md5(implode("", $cid));
}
21 changes: 14 additions & 7 deletions includes/preflight.inc
Expand Up @@ -175,13 +175,20 @@ function drush_preflight_prepare() {
drush_set_context('DRUSH_VENDOR_PATH', dirname($vendor_path));
drush_set_context('DRUSH_CLASSLOADER', $classloader);

// Set up for backwards-compatibility. New code should call
// \Drush::getVersion() and \Drush::getMajorVersion() directly
$drush_version = \Drush::getVersion();
$version_parts = explode('.', $drush_version);
define('DRUSH_VERSION', $drush_version);
define('DRUSH_MAJOR_VERSION', $version_parts[0]);
define('DRUSH_MINOR_VERSION', $version_parts[1]);
/*
* @deprecated. Use \Drush::getVersion().
*/
define('DRUSH_VERSION', \Drush::getVersion());

/*
* @deprecated. Use \Drush::getMajorVersion().
*/
define('DRUSH_MAJOR_VERSION', Drush::getMajorVersion());

/*
* @deprecated. Use \Drush::getMinorVersion().
*/
define('DRUSH_MINOR_VERSION', Drush::getMinorVersion());

// We need to load our services right away, as we cannot log
// or do much else until after this is done.
Expand Down
4 changes: 3 additions & 1 deletion lib/Drush.php
Expand Up @@ -6,6 +6,7 @@
*/

use League\Container\ContainerInterface;
use SebastianBergmann\Version;

/**
* Static Service Container wrapper.
Expand Down Expand Up @@ -60,7 +61,8 @@ class Drush {
public static function getVersion() {
if (!static::$version) {
$drush_info = static::drush_read_drush_info();
static::$version = $drush_info['drush_version'];
$instance = new Version($drush_info['drush_version'], DRUSH_BASE_PATH);
static::$version = $instance->getversion();
}
return static::$version;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Drush/Boot/DrupalBoot.php
Expand Up @@ -282,7 +282,7 @@ function bootstrap_drupal_root_validate() {
$version = drush_drupal_version($drupal_root);
$major_version = drush_drupal_major_version($drupal_root);
if ($major_version <= 6) {
return drush_set_error('DRUSH_DRUPAL_VERSION_UNSUPPORTED', dt('Drush !drush_version does not support Drupal !major_version.', array('!drush_version' => DRUSH_VERSION, '!major_version' => $major_version)));
return drush_set_error('DRUSH_DRUPAL_VERSION_UNSUPPORTED', dt('Drush !drush_version does not support Drupal !major_version.', array('!drush_version' => \Drush::getMajorVersion(), '!major_version' => $major_version)));
}

drush_bootstrap_value('drupal_root', $drupal_root);
Expand Down

0 comments on commit f503102

Please sign in to comment.