Skip to content

Commit 47f6d45

Browse files
committed
List jsk Github repos
Depends on ros/rosdistro#13011
1 parent c5d6bd1 commit 47f6d45

File tree

5 files changed

+83
-19
lines changed

5 files changed

+83
-19
lines changed

jsk_tools/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<build_depend>rosgraph_msgs</build_depend>
2020
<run_depend>python-percol</run_depend>
2121
<run_depend>python-colorama</run_depend>
22-
<run_depend>python-pygithub3</run_depend>
22+
<run_depend>python-github-pip</run_depend>
2323
<run_depend>python-slacker-cli</run_depend>
2424
<run_depend>python-texttable</run_depend>
2525
<run_depend>rosgraph_msgs</run_depend>

jsk_tools/src/git_commit_alias.py

+20-18
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
11
#!/usr/bin/env python
22

3-
# Generate commit aliases for jsk-ros-pkg developers
3+
"""Generate commit aliases for jsk-ros-pkg developers"""
4+
45
import subprocess
5-
from pygithub3 import Github
6+
from jsk_tools.github_lib import login_github
7+
68

7-
from getpass import getpass
8-
user = raw_input('GitHub User name: ')
9-
pw = getpass('Password: ')
109

11-
gh = Github(login=user, password=pw)
12-
result = gh.orgs.members.list('jsk-ros-pkg')
13-
for page in result:
14-
for member in page:
15-
user = gh.users.get(member.login)
10+
def main():
11+
gh = login_github()
12+
13+
org = gh.get_organization('jsk-ros-pkg')
14+
for user in org.get_members():
1615
try:
17-
name = user.name
18-
alias_name = name
16+
alias_name = name = user.name
1917
email = user.email
2018
if not email or email == "":
2119
raise Exception("No email specified")
22-
if len(alias_name.split(" ")) > 0:
20+
if len(name.split(" ")) > 0:
2321
alias_name = name.split(" ")[-1]
2422
alias_command = "commit-%s" % alias_name.lower()
2523
alias = "jsk-commit --author='%s <%s>'" % (name, email)
26-
subprocess.check_call(["git", "config", "--global",
27-
"alias.%s" % alias_command,
28-
alias])
24+
subprocess.check_call(
25+
["git", "config", "--global",
26+
"alias.%s" % alias_command, alias]
27+
)
2928
print "Added %s" % (alias_command)
30-
except:
31-
print "Failed to generate alias for %s" % (member.login)
29+
except Exception as e:
30+
print("Failed to generate alias for %s: %s" % (user.name, e))
31+
3232

33+
if __name__ == '__main__':
34+
main()

jsk_tools/src/jsk_tools/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
from . import video_directive
66
from . import sanity_lib
77
from . import cltool
8+
from . import github_lib

jsk_tools/src/jsk_tools/github_lib.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import __builtin__
2+
3+
import getpass
4+
import sys
5+
6+
import github
7+
8+
9+
def raw_input(prompt=None):
10+
if prompt:
11+
sys.stderr.write(str(prompt))
12+
return __builtin__.raw_input()
13+
14+
15+
gh = None
16+
17+
18+
def login_github():
19+
global gh
20+
if gh is None:
21+
username = raw_input('GitHub username: ')
22+
password = getpass.getpass('Password: ', stream=sys.stderr)
23+
gh = github.Github(username, password)
24+
return gh

jsk_tools/src/list_repos.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
3+
import argparse
4+
5+
from jsk_tools.github_lib import login_github
6+
7+
8+
def main():
9+
parser = argparse.ArgumentParser()
10+
parser.add_argument('--rosinstall', action='store_true',
11+
help='Outputs with rosinstall format.')
12+
args = parser.parse_args()
13+
14+
rosinstall = args.rosinstall
15+
16+
gh = login_github()
17+
18+
for org_name in ['jsk-ros-pkg', 'start-jsk']:
19+
org = gh.get_organization(org_name)
20+
for repo in org.get_repos():
21+
if rosinstall:
22+
if repo.private:
23+
uri_prefix = '[email protected]:'
24+
else:
25+
uri_prefix = 'https://github.com/'
26+
print('''\
27+
- git:
28+
local-name: {repo.full_name}
29+
uri: {uri_prefix}{repo.full_name}.git
30+
version: {repo.default_branch}'''.format(repo=repo,
31+
uri_prefix=uri_prefix))
32+
else:
33+
print(repo.full_name)
34+
35+
36+
if __name__ == '__main__':
37+
main()

0 commit comments

Comments
 (0)