Last active
August 29, 2015 14:14
-
-
Save jangaraj/9d7e9f6d5b1f30c02a02 to your computer and use it in GitHub Desktop.
Creating of submodules for https://github.com/zabbix/zabbix-community-repos
This file contains 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/python | |
# www.jangaraj.com | |
# Creating of submodules for https://github.com/zabbix/zabbix-community-repos | |
import os | |
import commands | |
# format of file | |
# https://github.com/jangaraj/Zabbix-Template-App-Zenoss Template App Zenoss (jangaraj) | |
with open('repos.txt') as f: | |
content = f.readlines() | |
for line in content: | |
line = line[:-1] | |
pos = line.find(' ') | |
github = line[0:pos] | |
project = line[pos+1:] | |
dir = project.replace(' ', '-') | |
# submodule have to link to project, particular dir of project is not allowed | |
if '/tree/' in github: | |
pos2 = github.find('/tree/') | |
githubsubmodule = github[0:pos2] | |
else: | |
githubsubmodule = github | |
print "%s: %s - %s (%s)" % (project, dir, github, githubsubmodule) | |
os.makedirs(dir) | |
command = "git submodule add \"" + githubsubmodule + "\" \"" + dir + "/repo\"" | |
print command | |
rc, outputs = commands.getstatusoutput(command) | |
command = "echo \"[Link - " + project + "](" + github +")\" > \"" + dir + "/README.md\"" | |
print command | |
rc, outputs = commands.getstatusoutput(command) | |
command = "git add \"" + dir + "\"" | |
print command | |
rc, outputs = commands.getstatusoutput(command) | |
command = "git commit -am '" + dir + "'" | |
print command | |
rc, outputs = commands.getstatusoutput(command) | |
print "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment