-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheckoutGeonovumRepos.py
44 lines (40 loc) · 1.12 KB
/
checkoutGeonovumRepos.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
37
38
39
40
41
42
43
44
#!/usr/bin/python3
#
# author: Wilko Quak ([email protected])
#
# Dit script checkt alle Geonovum repositories uit en houdt ze up to date.
# Vereisten:
# - Github client is geinstalleerd: (sudo apt-get install gh)
# - Authenticatie regel (export GH_TOKEN=)
#
import subprocess
import json
import os
from git import Repo
output = subprocess.check_output('gh repo list Geonovum -L 400 --json name,isEmpty',shell=True)
data = json.loads(output)
#
# For small tests you can run the script with only this repo.
#
#data = json.loads('''
#[
# {
# #"name": "dso-cimop"
# },
# {
# "name": "DashboardGit"
# }
#]
#''')
for x in data:
repo = x['name']
isEmpty = x['isEmpty']
if isEmpty:
print('skipping repo {} because empty.'.format(repo))
elif os.path.isdir(repo):
print('repo {} exists updating'.format(repo))
subprocess.check_output('cd {}; gh repo sync'.format(repo),shell=True)
else:
print('repo {} does not exist checking out'.format(repo))
print('gh repo clone Geonovum/{}'.format(repo))
subprocess.check_output('gh repo clone Geonovum/{}'.format(repo),shell=True)