Skip to content

Instantly share code, notes, and snippets.

@jangaraj
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jangaraj/9d7e9f6d5b1f30c02a02 to your computer and use it in GitHub Desktop.
Save jangaraj/9d7e9f6d5b1f30c02a02 to your computer and use it in GitHub Desktop.
#!/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