Skip to content

Instantly share code, notes, and snippets.

Avatar

John Dillick jdillick

View GitHub Profile
@jdillick
jdillick / find_closest_sha1.py
Created Jan 17, 2013
Found this little gem of python for comparing a git repo to an un-versioned copy of the code. I returns the closest commit hash from the git repository corresponding to your code. This works great when you don't know what version of the code you have running.
View find_closest_sha1.py
#!/usr/bin/env python
import subprocess
import shlex
import sys
import os
import operator
gitdir,workdir=map(os.path.realpath,sys.argv[1:3])
os.chdir(gitdir)
proc=subprocess.Popen(shlex.split('git rev-list --all'),stdout=subprocess.PIPE)
You can’t perform that action at this time.