tvdstaaij / node-git-describe

Git describe information at runtime, with semver support
36 stars 5 forks source link

Add option to generate dirty state hash of tracked files #14

Closed aalexgabi closed 4 years ago

aalexgabi commented 4 years ago

This generates a unique id for for a given set of uncommitted changes in tracked files.

git diff | sha1sum | head -c 7

Here is an npm script that illustrates the idea behind dirty hash:

"git:version": "set -o pipefail && (set -o pipefail && git tag --points-at HEAD | grep -oP '^v\\d+\\.\\d+\\.\\d+$' | tr -d 'v' | xargs echo -n) || (set -o pipefail && git rev-parse --short HEAD | xargs echo -n) && (git diff-index --quiet HEAD || (set -o pipefail && echo -n '-dirty-' && git diff | sha1sum | head -c 7))",
tvdstaaij commented 4 years ago

Hello, thank you for your interest in this module.

The purpose of this module is to provide the information that you would normally get from git describe using a JS API. I feel that adding information derived from other git inspection commands is beyond the intended scope. It would be better suited to a git diff module, git utilities module, or maybe even its own module.