1
0
Fork 0

Make submodules script work in both 2 and 3 pythons

This commit is contained in:
Gregory Eremin 2016-01-10 22:30:45 +03:00
parent 71a8441a8b
commit 154c493b64
1 changed files with 5 additions and 7 deletions

View File

@ -7,18 +7,16 @@ def main():
source = open(".gitmodules").read() source = open(".gitmodules").read()
paths = re.findall(r"path = (.*)", source) paths = re.findall(r"path = (.*)", source)
print "github.com/localhots/satan {}".format(path_sha1(".")) print("github.com/localhots/satan {}".format(path_sha1(".")))
for path in paths: for path in paths:
print "{repo} {sha}".format( print("{} {}".format(path[7:], path_sha1(path)))
repo = path[7:],
sha = path_sha1(path)
)
def path_sha1(path): def path_sha1(path):
cmd = "cd {} && git rev-parse HEAD".format(path) cmd = "cd {} && git rev-parse HEAD".format(path)
sp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) sp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
sha1 = sp.stdout.read()[:-1] sha1 = sp.stdout.read()[:-1].decode("ascii")
return sha1 return sha1
if __name__ == "__main__": main() if __name__ == "__main__":
main()