-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloneSubrepositories
executable file
·59 lines (46 loc) · 2.29 KB
/
cloneSubrepositories
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /usr/bin/env python3
import argparse
import subprocess
import os
dirname = os.path.dirname(os.path.realpath(__file__))
parser = argparse.ArgumentParser(description='Stop the ' +
'containerized versions of TwinePM ' +
'services.')
branch_default = os.environ.get('TWINEPM_BRANCH') or 'dev'
parser.add_argument('--branch', '-b', nargs=1, default=branch_default,
help='set the branch of the repositories', type=str)
default_subrepo_list = os.environ.get('TWINEPM_SUBREPO_LIST')
if default_subrepo_list:
default_subrepo_list = default_subrepo_list.split(' ')
if not len(default_subrepo_list):
raise Exception('No subrepos provided.')
else:
default_subrepo_list = ['client', 'diskdb', 'logic', 'memorydb',
'scripts', 'web']
subrepo_list_help = 'set the subrepositories which will be cloned.'
parser.add_argument('--subrepo-list', '-l', nargs='+',
default=default_subrepo_list, help=subrepo_list_help,
type=list)
site_help = 'set the site from which repositories are cloned'
default_site = os.environ.get('TWINEPM_REPO_SITE') or 'https://github.com'
parser.add_argument('--site', '-s', nargs=1, default=default_site,
help=site_help, type=str)
default_owner = os.environ.get('TWINEPM_REPO_OWNER') or 'furkleindustries'
parser.add_argument('--owner', '-o', nargs=1, default=default_owner,
help='set the owner of the subrepositories', type=str)
envvar = os.environ.get('TWINEPM_REPO_NAME')
default_repo_base_name = envvar or 'twine-package-manager'
parser.add_argument('--base-name', '-n', nargs=1,
default=default_repo_base_name, help='the name ' +
'of the superrepository, which is used to ' +
'compute the full subrepository names',
type=str)
args = parser.parse_args()
for subrepo_name in args.subrepo_list:
url = '{}/{}/{}-{}'.format(args.site, args.owner, args.base_name,
subrepo_name)
file_path = '{}/{}'.format(dirname, subrepo_name)
cmd = ['git', 'clone', url, '-b', args.branch, file_path]
proc = subprocess.Popen(cmd)
proc.communicate()
print('Subrepositories cloned.')