1
0
Fork 0

Add a script that prints submodules info in Glockfile compatible format

This commit is contained in:
Gregory Eremin 2016-01-10 20:30:02 +03:00
parent 38171549fb
commit 3a09a2ed29
1 changed files with 23 additions and 0 deletions

23
submodules-to-glockfile.py Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/python
import re
import subprocess
def main():
source = open(".gitmodules").read()
paths = re.findall(r"path = (.*)", source)
for path in paths:
print "{repo} {sha}".format(
repo = path[7:],
sha = path_sha1(path)
)
def path_sha1(path):
cmd = "cd {} && git rev-parse HEAD".format(path)
sp = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
sha1 = sp.stdout.read()[:-1]
return sha1
if __name__ == "__main__": main()