Hi!
Searching the Environment Indicator issue queue for "git" turns up a number of issues past and present that show the usefulness but also the finickiness of this feature.

In this comment in issue #2636670-18: "git describe --all" is unreliable, e0ipso decided that the code to fetch the git information would be removed from the Drupal 8 version. It is still however possible to set and display this information in environment indicator.

This issue is regarding adding information on how to set the git information to the documentation. Both for git and not git environments

The Drupal 7 version included a script that could be used on Acquia Cloud to do this as I believe on production the directory is not managed by git, so running a git command would have returned nothing and left it blank.

This script, environment-indicator.sh is still in the Drupal 7 version in the samples directory.

environment-indicator.sh

#!/bin/sh
#
# Cloud Hook: environment-indicator
#
# The post-code-deploy hook is run whenever you use the Workflow page to
# deploy new code to an environment, either via drag-drop or by selecting
# an existing branch or tag from the Code drop-down list. This hook will
# maintain a variable with the realease information.

site="$1"
target_env="$2"
source_branch="$3"
deployed_tag="$4"
repo_url="$5"
repo_type="$6"

if [ "$source_branch" != "$deployed_tag" ]; then
    drush @$site.$target_env vset --exact environment_indicator_remote_release.$target_env $source_branch
else
    drush @$site.$target_env vset --exact environment_indicator_remote_release.$target_env $deployed_tag
fi
echo "Updated release info for environment indicator."

For Drupal 8 with Drush 9 the environment_indicator.current_release state can be set using the Drush command:
drush sset environment_indicator.current_release "Hello World!"

This command will get the current branch followed by the latest tag, number of commits since the tag, and the short current commit hash. (ie. dev 0.6.1-8-g629134f)
drush sset environment_indicator.current_release "$(git describe --contains --all HEAD;echo " ";git describe --always)"

This command will get the latest tag, number of commits since the tag, and the short current commit hash. (ie. 0.6.1-8-g629134f)
git describe --always |drush sset environment_indicator.current_release -

If this is in a git environment git hooks can be used to set this information using the git post-commit and post-checkout hooks so that after every commit or checkout it is updated. It would be a good idea to give links to where user could find more information about using git hooks and possibly about sharing git hooks if they are in a team.

I hope this sparks some ideas of what could be included in the documentation regarding setting git information to display.

Comments

frederickjh created an issue.

moshe weitzman’s picture

Great info in here. Thanks.

Elijah Lynn’s picture

This is huge! Every deploy should list the version that it is running so we know what bugs should be reported against. Especially useful in dealing with multiple servers and seeing which ones are still serving old code.

I'd like to see this get a bit more visible.