Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jsk_tools] List jsk Github repos #1463

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion jsk_tools/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<run_depend>cv_bridge</run_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-tabulate-pip</run_depend>
<run_depend>python-texttable</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()