Created
October 12, 2017 09:14
-
-
Save akullpp/1a04c8dc11447952d8aff803ba8803b6 to your computer and use it in GitHub Desktop.
Get all repositories from stash
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/env python | |
# -*- coding: utf-8 -*- | |
import stashy | |
from sys import argv | |
stash = stashy.connect('url', 'username', 'password') | |
def getProjects(): | |
projects = {} | |
for webProject in stash.projects[argv[1]].repos.list(): | |
for cloneUrl in webProject['links']['clone']: | |
if cloneUrl['name'] == 'ssh': | |
projects[webProject['name']] = (webProject['links']['self'][0]['href'], cloneUrl['href']) | |
return projects | |
def constructConfig(projects): | |
with open('%s_repositories' %argv[1], 'w') as cfg: | |
for name, url in projects.items(): | |
cfg.write("%s\n" %url[1]) | |
if __name__ == '__main__': | |
print 'Searching %s/projects' %argv[1] | |
projects = getProjects() | |
print 'Found %d projects' %len(projects) | |
constructConfig(projects) | |
print 'Config constructed' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Archiving old script, probably won't work anymore.