def rev_to_hash(path, rev): '''Returns the hash of the nth commit''' if not rev.isdigit(): return rev prev_path = os.getcwd() os.chdir(path) # Get the total amount of commits num = git_command('rev-list --count HEAD') rev = git_command('log --format="%H" -1 --skip=' + str(int(num) - int(rev)) + ' HEAD') os.chdir(prev_path) print 'Hash', rev return rev.strip()
def find_previous_commit(commit): if not (commit.isdigit() and len(commit) < 5): out = git_command('rev-list --count ' + commit) commit = out.strip() d = os.listdir('./') for i in xrange(int(commit) - 1, 0, -1): if str(i) in d: return str(i) return ''
def get_rev(path): prev_path = os.getcwd() os.chdir(path) rev = git_command('rev-list --count HEAD') os.chdir(prev_path) print 'Revision', rev return rev.strip()
def rev_to_svn_rev(path, rev): prev_path = os.getcwd() os.chdir(path) h = rev_to_hash(path, rev) rev = git_command('svn find-rev ' + h) os.chdir(prev_path) print 'svn revision', rev return rev.strip()
def sync_commits(hymls_path, fvm_path, commit): '''Sync the hymls and fvm versions''' prev_path = os.getcwd() # Get the hymls commit time os.chdir(hymls_path) t = git_command('log --format="%at" -1 ' + commit) #Set the fvm commit os.chdir(fvm_path) git_command('fetch', True) git_command('svn fetch', True) git_command('reset --hard') git_command('svn rebase', True) h = git_command('log -1 --format="%H" --before=' + t.strip()) git_command('reset --hard ' + h) os.chdir(prev_path)
def set_commit(commit): git_command('reset --hard ' + commit)