Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Get git sha

def get_git_sha():
    locations_to_try = ['git', '/bin/git', '/usr/bin/git', '/usr/local/bin/git']
    git_binary, sha, timestamp = None, None, None
    for location in locations_to_try:
        sha = os.popen(f'{location} rev-parse HEAD').read().strip()
        if (len(sha) > 10) and ' ' not in sha:
            git_binary = str(location)
            break
    if not sha:
        return None
    timestamp = os.popen(f"{git_binary} show --no-patch --no-notes --pretty='%at' {sha}").read().strip()
    timestamp = str(datetime.fromtimestamp(int(timestamp)))
    return git_binary, sha, timestamp
Comment

PREVIOUS NEXT
Code Example
Python :: Mixed Fractions in python 
Python :: get_int python 
Python :: c is better than python 
Python :: sklearn impute 
Python :: if a or b in python 
Python :: Return an RDD with the keys of each tuple. 
Python :: how to change color of square in pygame with keypress 
Python :: File "main.py", line 21 print("total harga:idr", bakso bulat +str Minuman Drink): ^ SyntaxError: invalid syntax 
Python :: python web server oneliner 
Python :: draw a bow tie in python 
Python :: medium seaaborn mathplot diesign styles 
Python :: deduplication jaccard python 
Python :: how to push the element to array in python 
Python :: how many orders has customer made database python 
Python :: command to update pip 
Shell :: linux check if x11 
Shell :: npm install upgrade react version react-scripts 
Shell :: postgres status ubuntu 
Shell :: how to restart nginx 
Shell :: brew uninstall mysql 
Shell :: check bios version cmd 
Shell :: how to check the repository name in git 
Shell :: ubuntu tweak 
Shell :: uninstalling eclipse from ubuntu 
Shell :: curl file share 
Shell :: ping command not found docker 
Shell :: install jq on mac 
Shell :: how to pip install asyncio 
Shell :: how to run requirements.txt in python 
Shell :: run requirements.txt conda 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =