Last active
March 13, 2019 00:25
-
-
Save nicerobot/91f184cb9ac802b46fa13c9a8b850c31 to your computer and use it in GitHub Desktop.
Hash tracked git files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Useful for, for example, versioning docker images built from subdirectories in a mono-repo. | |
cd ${1:-.} || exit | |
git ls-tree -r --name-only $(git rev-parse --symbolic-full-name --abbrev-ref HEAD) \ | |
| while read f; do [[ -d "${f}" ]] || [[ -f "${f}" ]] && echo ${f}; done \ | |
| sort -fd \ | |
| tr '\n' '\0' \ | |
| xargs -0 openssl sha1 \ | |
| openssl sha1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment