You are here

function environment_indicator_environment_indicator_matched_indicator_alter in Environment Indicator 7.2

Implements hook_environment_indicator_matched_indicator_alter().

File

./environment_indicator.module, line 595
Module implementation file.

Code

function environment_indicator_environment_indicator_matched_indicator_alter(&$environment_info) {
  if (variable_get('environment_indicator_git_support', TRUE)) {

    // First check to see if a variable is explicitly set.
    if (variable_get('environment_indicator_remote_release')) {
      $release = variable_get('environment_indicator_remote_release');
    }
    elseif (!empty($_ENV['AH_SITE_ENVIRONMENT'])) {

      // Acquia cloud environments don't have a .git directory to check. Instead, we
      // need to maintain the release string ourselves using the post deploy hooks.
      // Display the contents of the variable if it is not empty. If it is empty
      // then a warning should be set in the status report about the hook being
      // missing for the environment.
      $release = variable_get('environment_indicator_remote_release.' . $_ENV['AH_SITE_ENVIRONMENT'], NULL);
    }
    else {

      // Show the git branch, if it exists.
      if (command_exists('git') && ($git_describe = environment_indicator_execute_os_command('git describe --all'))) {

        // Execute "git describe --all" and get the last part of heads/7.x-2.x as the
        // tag/branch.
        if (empty($git_describe)) {
          return;
        }
        $tag_branch_parts = explode('/', $git_describe);
        $release = end($tag_branch_parts);
      }
    }
  }
  if (!empty($release)) {
    $environment_info['git_branch'] = $release;
  }
}