Skip to content

Commit

Permalink
List jsk Github repos
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Oct 21, 2016
1 parent c5d6bd1 commit d982720
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 19 deletions.
2 changes: 1 addition & 1 deletion jsk_tools/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<build_depend>rosgraph_msgs</build_depend>
<run_depend>python-percol</run_depend>
<run_depend>python-colorama</run_depend>
<run_depend>python-pygithub3</run_depend>
<run_depend>python-github-pip</run_depend>
<run_depend>python-slacker-cli</run_depend>
<run_depend>python-texttable</run_depend>
<run_depend>rosgraph_msgs</run_depend>
Expand Down
38 changes: 20 additions & 18 deletions jsk_tools/src/git_commit_alias.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,34 @@
#!/usr/bin/env python

# Generate commit aliases for jsk-ros-pkg developers
"""Generate commit aliases for jsk-ros-pkg developers"""

import subprocess
from pygithub3 import Github
from jsk_tools.github_lib import login_github


from getpass import getpass
user = raw_input('GitHub User name: ')
pw = getpass('Password: ')

gh = Github(login=user, password=pw)
result = gh.orgs.members.list('jsk-ros-pkg')
for page in result:
for member in page:
user = gh.users.get(member.login)
def main():
gh = login_github()

org = gh.get_organization('jsk-ros-pkg')
for user in org.get_members():
try:
name = user.name
alias_name = name
alias_name = name = user.name
email = user.email
if not email or email == "":
raise Exception("No email specified")
if len(alias_name.split(" ")) > 0:
if len(name.split(" ")) > 0:
alias_name = name.split(" ")[-1]
alias_command = "commit-%s" % alias_name.lower()
alias = "jsk-commit --author='%s <%s>'" % (name, email)
subprocess.check_call(["git", "config", "--global",
"alias.%s" % alias_command,
alias])
subprocess.check_call(
["git", "config", "--global",
"alias.%s" % alias_command, alias]
)
print "Added %s" % (alias_command)
except:
print "Failed to generate alias for %s" % (member.login)
except Exception as e:
print("Failed to generate alias for %s: %s" % (user.name, e))


if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions jsk_tools/src/jsk_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
from . import video_directive
from . import sanity_lib
from . import cltool
from . import github_lib
24 changes: 24 additions & 0 deletions jsk_tools/src/jsk_tools/github_lib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import __builtin__

import getpass
import sys

import github


def raw_input(prompt=None):
if prompt:
sys.stderr.write(str(prompt))
return __builtin__.raw_input()


gh = None


def login_github():
global gh
if gh is None:
username = raw_input('GitHub username: ')
password = getpass.getpass('Password: ', stream=sys.stderr)
gh = github.Github(username, password)
return gh
37 changes: 37 additions & 0 deletions jsk_tools/src/list_repos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python

import argparse

from jsk_tools.github_lib import login_github


def main():
parser = argparse.ArgumentParser()
parser.add_argument('--rosinstall', action='store_true',
help='Outputs with rosinstall format.')
args = parser.parse_args()

rosinstall = args.rosinstall

gh = login_github()

for org_name in ['jsk-ros-pkg', 'start-jsk']:
org = gh.get_organization(org_name)
for repo in org.get_repos():
if rosinstall:
if repo.private:
uri_prefix = '[email protected]:'
else:
uri_prefix = 'https://github.com/'
print('''\
- git:
local-name: {repo.full_name}
uri: {uri_prefix}/{repo.full_name}.git
version: {repo.default_branch}'''.format(repo=repo,
uri_prefix=uri_prefix))
else:
print(repo.full_name)


if __name__ == '__main__':
main()

0 comments on commit d982720

Please sign in to comment.