Created
August 17, 2014 05:27
-
-
Save foreverbell/2506f0eb1645226cc2c8 to your computer and use it in GitHub Desktop.
Recover git submodules from .gitmodules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # encoding: utf-8 | |
| import ConfigParser | |
| import sys | |
| import StringIO | |
| data = StringIO.StringIO('\n'.join(line.strip() for line in open(".gitmodules", "r"))) | |
| config = ConfigParser.SafeConfigParser() | |
| config.readfp(data) | |
| sections = config.sections() | |
| with open("init-modules.sh", "w") as f : | |
| f.write("#!/bin/sh\n") | |
| for s in sections : | |
| path = config.get(s, "path") | |
| url = config.get(s, "url") | |
| f.write("git submodule add %s %s\n" % (url, path)) | |
| f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment