|
1 | 1 | #!/usr/bin/env python
|
2 | 2 |
|
3 |
| -# Generate commit aliases for jsk-ros-pkg developers |
| 3 | +"""Generate commit aliases for jsk-ros-pkg developers""" |
| 4 | + |
4 | 5 | import subprocess
|
5 |
| -from pygithub3 import Github |
| 6 | +from jsk_tools.github_lib import login_github |
| 7 | + |
6 | 8 |
|
7 |
| -from getpass import getpass |
8 |
| -user = raw_input('GitHub User name: ') |
9 |
| -pw = getpass('Password: ') |
10 | 9 |
|
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(): |
16 | 15 | try:
|
17 |
| - name = user.name |
18 |
| - alias_name = name |
| 16 | + alias_name = name = user.name |
19 | 17 | email = user.email
|
20 | 18 | if not email or email == "":
|
21 | 19 | raise Exception("No email specified")
|
22 |
| - if len(alias_name.split(" ")) > 0: |
| 20 | + if len(name.split(" ")) > 0: |
23 | 21 | alias_name = name.split(" ")[-1]
|
24 | 22 | alias_command = "commit-%s" % alias_name.lower()
|
25 | 23 | 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 | + ) |
29 | 28 | 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 | + |
32 | 32 |
|
| 33 | +if __name__ == '__main__': |
| 34 | + main() |
0 commit comments