Skip to content

Add ability to show tag/commit/dirty #99

@keiranmraine

Description

@keiranmraine

This is a great tool to show users when the docs were last updated, but it would be exceptionally helpful to be able to embed the version/tag if available, falling back to head commit and an indicator if the workspace is dirty.

The examples below can only be attempted after confirming .git exists.

e.g.

# repo with no tags and dirty workspace
$ GIT_REV=$(git describe --dirty || (git show --format="%h" --no-patch | tr -d '\n' && git diff --quiet || echo '-dirty'))
fatal: No names found, cannot describe anything.
$ echo $GIT_REV
27d95e8-dirty

# repo with tags
$ GIT_REV=$(git describe --dirty || (git show --format="%h" --no-patch | tr -d '\n' && git diff --quiet || echo '-dirty'))
$ echo $GIT_REV
2.1.1-1-g50fabe3

## with tags and dirty
$ GIT_REV=$(git describe --dirty || (git show --format="%h" --no-patch | tr -d '\n' && git diff --quiet || echo '-dirty'))
$ echo $GIT_REV
2.1.1-1-g50fabe3-dirty

# with tag checked out
$ GIT_REV=$(git describe --dirty || (git show --format="%h" --no-patch | tr -d '\n' && git diff --quiet || echo '-dirty'))
$ echo $GIT_REV
2.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions