-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosa.py
executable file
·36 lines (30 loc) · 1001 Bytes
/
osa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
import os
import sys
import git
import requests
import yaml
# Get the list of projects
url = 'https://opendev.org/openstack/governance/raw/branch/master/reference/projects.yaml'
r = requests.get(url)
deliverables = yaml.load(r.text).get('OpenStackAnsible').get('deliverables')
git_repos = deliverables['openstack-ansible-roles']['repos']
repos = []
for repo in git_repos:
ns, role = repo.split('/')
path = "https://opendev.org/%s" % (repo)
clone_path = 'roles/%s' % role
# Get the latest code
if os.path.isdir(clone_path):
print("%s: resetting to origin/master and pulling" % repo)
repo = git.Repo(clone_path)
repo.git.reset('--hard')
repo.heads.master.checkout()
repo.git.reset('--hard')
repo.git.clean('-xdf')
repo.remotes.origin.pull()
else:
print("%s: cloning" % repo)
repo = git.Repo.clone_from(path, clone_path)
# Add to imported list of repos
repos.append(repo)