Created
May 10, 2018 09:39
-
-
Save minhlab/eff510f4c5c59a35eb023d41152c178d to your computer and use it in GitHub Desktop.
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
import os | |
from datetime import date | |
# git diff --staged is faster than git diff (of everything) so let's do it first | |
changed = os.popen('git diff').read().strip() != '' | |
if changed: | |
version = date.today().strftime('%Y-%m-%d') | |
else: | |
version = (os.popen('git show -s --format=%ci').read()[:10] + | |
os.popen('git show -s --format=-%h').read().strip()) | |
if __name__ == '__main__': | |
print(version) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment