6
data = file(path).read()
7
h.update("blob %d\0" % len(data))
6
data = file(path, 'rb').read()
7
h.update("blob %d\0" % len(data))
12
commithash = os.popen('git-rev-parse --verify HEAD 2>/dev/null').read().strip()
14
raise ValueError("Couldn't get hash")
15
if os.getuid() == os.stat(".git/index").st_uid:
16
os.system('git-update-index --refresh >/dev/null')
18
print "NOT updating git cache, local changes might not be detected"
19
changed = bool(os.popen('git-diff-index -r HEAD').read())
20
return commithash, changed
12
commithash = os.popen('git-rev-parse --verify HEAD 2>/dev/null').read().strip()
14
raise ValueError("Couldn't get hash")
15
if os.getuid() == os.stat(".git/index").st_uid:
16
os.system('git-update-index --refresh >/dev/null')
18
print "NOT updating git cache, local changes might not be detected"
19
changed = bool(os.popen('git-diff-index -r HEAD').read())
20
return commithash, changed
22
22
def snapshot_info():
23
info = file('commithash').read().split('\n')
28
for line in [a for a in info[2:] if a]:
29
[mode, tag, sha, path] = line.split(None, 4)
32
if gitsha(path) != sha:
35
return commithash, changed
23
info = file('commithash').read().split('\n')
28
for line in [a for a in info[2:] if a]:
29
[mode, tag, sha, path] = line.split(None, 4)
32
if gitsha(path) != sha:
35
return commithash, changed
42
return snapshot_info()
44
return 'Unknown', False
42
return snapshot_info()
44
return 'Unknown', False
46
46
def get_info_str():
47
commithash, changed = get_info()
49
changed = " + local changes"
47
commithash, changed = get_info()
49
changed = " + local changes"
53
return "%s%s" % (commithash, changed)
53
return "%s%s" % (commithash, changed)