We’ve been enjoying moving information the other way, so Ignition knows what its git directory is looking at. This will require some tweaks to tag paths or if your git root isn’t at the projects level, but the basic idea should be easy to work with. We call this from a project update event and it works well:
def update_git_tags():
import subprocess
projects_directory = '/usr/local/bin/ignition/data/projects'
description_tagpath = '[default]git/description'
branch_tagpath = '[default]git/branch'
# If using annotated tags in git for releases, remove the "--tags" on
# this command line, as it is only there to include non-annotated tags:
desc_args = '/usr/bin/git -C {pd} describe --broken --always --tags'.split()
desc_args[2] = projects_directory
description_string = subprocess.check_output(desc_args)
description_string = description_string.strip()
branch_args = '/usr/bin/git -C {pd} branch --show-current'.split()
branch_args[2] = projects_directory
branch_string = subprocess.check_output(branch_args)
branch_string = branch_string.strip()
#logger.info('git update: branch={} description={}'.format(branch_string, description_string))
tagpaths = [description_tagpath, branch_tagpath]
values = [description_string, branch_string]
system.tag.writeBlocking(tagpaths, values)