forked from synit/synit
23 lines
611 B
Python
Executable File
23 lines
611 B
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
def x(cmd):
|
|
return subprocess.check_output(cmd, shell=True)
|
|
|
|
uncommitted = x('git status --porcelain=v1 -- .')
|
|
dirty = len(uncommitted) > 0
|
|
|
|
if dirty:
|
|
commithash = x('git --no-pager log -n 1 --pretty=tformat:"%h" -- .').strip()
|
|
timestamp = int(time.time())
|
|
else:
|
|
(commithash, timestamp) = x('git --no-pager log -n 1 --pretty=tformat:"%h %ct" -- .').strip().split()
|
|
timestamp = int(timestamp)
|
|
|
|
commithash = commithash.decode('utf-8')
|
|
timestamp = time.strftime("%Y%m%d%H%M%S", time.gmtime(timestamp))
|
|
print(f'_git{timestamp}')
|