def do_open(client, args): """Create a new issue.""" repository = get_repository_name(args.repository) print 'Please enter the long description for this issue.' print 'Starting your text editor:' desc_text = text_from_editor() print client.issues.open(repository, args.title, desc_text)
def do_list(client, args): """List a repository's collaborators.""" repository = get_repository_name(args.repository) collaborators = client.repos.list_collaborators(repository) if not collaborators: print 'There are no collaborators for %s.' % repository else: print 'The following people are collaborating on %s:' % \ repository for collaborator in collaborators: print collaborator
def do_list(client, args): """Command to list the issues for a given repository.""" repository = get_repository_name(args.repository) status = args.status or 'open' issues = client.issues.list(repository, state=status) if not issues: print '%s has no %s issues' % (repository, status) else: print '%s has the following %s issues' % (repository, status) print 'Issue# - Title' for issue in issues: print '%s - %s' % (issue.number, issue.title)
def get(client, args): repository = get_repository_name(args.repository) try: issue = client.issues.show(repository, args.number) comments = client.issues.comments(repository, args.number) except: die( """Unable to retrieve the issue because of the following error: %s: %s """ % (sys.exc_info()[0], sys.exc_info()[1])) print 'Issue #%d: %s' % (issue.number, issue.title) print 'Opened by %s on %s at %s' % (issue.user, issue.created_at.date(), issue.created_at.strftime('%H:%M:%S')) print 'Last updated on %s at %s' % (issue.updated_at.date(), issue.updated_at.strftime('%H:%M:%S')) if issue.labels: print 'Labels:' for label in issue.labels: print '* %s' % label print 'Long description:' print_enclosed_text(issue.body) if comments: for comment in comments: print_comment(comment)
def remlabel(client, args): repository = get_repository_name(args.repository) print client.issues.remove_label(repository, args.number, args.label)
def comment(client, args): repository = get_repository_name(args.repository) print 'Starting your text editor, so that you can compose your comment:' comment_text = text_from_editor() print client.issues.comment(repository, args.number, comment_text)
def close(client, args): """Close an existing open issue.""" repository = get_repository_name(args.repository) print client.issues.close(repository, args.number)
def add(client, args): """Add a collaborator to a repo.""" repository = get_repository_name(args.repository) repository = remove_username(repository) print client.repos.add_collaborator(repository, args.user)
def remove(client, args): """Remove a collaborator from a repo.""" repository = get_repository_name(args.repository) repository = remove_username(repository) print client.repos.remove_collaborator(repository, args.user)