-
Notifications
You must be signed in to change notification settings - Fork 2
/
push_repositories_to_github.py
64 lines (51 loc) · 2.14 KB
/
push_repositories_to_github.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
Example:
$ ipython push_repositories_to_github.py ~/opensim2git_local/ruby_git_repos
"""
import os
import sys
from common import *
# Preliminaries.
# --------------
myprint('Obtaining dependencies...')
call('sudo apt-get install curl')
git_repos_dir = os.path.join(local_dir, 'ruby_git_repos')
# Find out where we'll be publishing the repositories on GitHub.
if 'OPENSIMTOGIT_GITHUB_USERNAME' in os.environ:
github_username = os.environ['OPENSIMTOGIT_GITHUB_USERNAME']
else:
github_username = raw_input('Enter your GitHub username: ')
# Put the repositories on GitHub.
# -------------------------------
def push_to_github(local_relpath, description, private):
# For background, see `man curl` and
# http://developer.github.com/v3/repos/.
myprint('Pushing %s' % local_relpath)
github_name = local_relpath
# Delete the repository on GitHub, in case it already exists.
call("curl -u {0} -X DELETE "
"'https://api.github.com/repos/opensim-org/{1}'".format(github_username,
github_name))
# Create the new repository.
# http://developer.github.com/guides/getting-started/#create-a-repository
json_parameters = ('{"name":"%s", '
'"description": "%s", '
'"auto_init": false, '
'"private": %s, '
'"homepage": "opensim.stanford.edu", '
'"team_id": 501023, '
'"gitignore_template": "C++"}' % (github_name, description,
private))
call("curl -u {0} -d '{1}' https://api.github.com/orgs/opensim-org/repos".format(
github_username, json_parameters))
with cd(os.path.join(git_repos_dir, local_relpath)):
call('git remote rm opensim-org')
call('git remote add opensim-org [email protected]:opensim-org/{0}.git'.format(
github_name))
call('git push opensim-org --all')
call('git push opensim-org --tags')
push_to_github('cfsqp', cfsqp_description, 'true')
push_to_github('opensim-core', opensim_core_description, 'true')
push_to_github('opensim-legacy',
opensim_legacy_description, 'true')
push_to_github('opensim-models', opensim_models_description, 'true')