Beispiel #1
0
def do_open(client, args):
    """Create a new issue."""
    repository = get_working_repo(client, args.repository)
    print('Please enter the long description for this issue.')
    print('Starting your text editor:')
    desc_text = text_from_editor()
    repository.create_issue(args.title, body=desc_text)
Beispiel #2
0
def do_open(client, args):
    """Create a new issue."""
    repository = get_working_repo(client, args.repository)
    print('Please enter the long description for this issue.')
    print('Starting your text editor:')
    desc_text = text_from_editor()
    repository.create_issue(args.title, body=desc_text)
Beispiel #3
0
def remlabel(client, args):
    repository = get_working_repo(client, args.repository)
    try:
        label = repository.get_label(args.label)
        label.delete()
    except GithubException as e:
        die('''Unable to delete label %s from this repository.
Error message: %s
''' % (args.label, e.data['message']))
    print('Label removed.')
Beispiel #4
0
def remlabel(client, args):
    repository = get_working_repo(client, args.repository)
    try:
        label = repository.get_label(args.label)
        label.delete()
    except GithubException as e:
        die('''Unable to delete label %s from this repository.
Error message: %s
''' % (args.label, e.data['message']))
    print('Label removed.')
Beispiel #5
0
def remlabel(client, args):
    issue = get_working_issue(client, args)
    repository = get_working_repo(client, args.repository)
    try:
        label = repository.get_label(args.label)
    except GithubException as e:
        die('''Unable to find the label %s in this repository.
            It cannot be removed from the issue at this time.
            Error message: %s
            ''' % (args.label, e.data['message']))
    issue.remove_from_labels(label)
Beispiel #6
0
def remlabel(client, args):
    issue = get_working_issue(client, args)
    repository = get_working_repo(client, args.repository)
    try:
        label = repository.get_label(args.label)
    except GithubException as e:
        die('''Unable to find the label %s in this repository.
            It cannot be removed from the issue at this time.
            Error message: %s
            ''' % (args.label, e.data['message']))
    issue.remove_from_labels(label)
Beispiel #7
0
def do_list(client, args):
    """Command to list the issues for a given repository."""
    repository = get_working_repo(client, args.repository)
    status = args.status or 'open'
    issues = list(repository.get_issues(state=status))
    if not issues:
        print('%s has no %s issues' % (repository.full_name, status))
    else:
        print('%s has the following %s issues' % (repository.full_name, status))
        print('Issue# - Title')
    for issue in issues:
        print('%s - %s' % (issue.number, issue.title))
Beispiel #8
0
def addlabel(client, args):
    # xxx Make this configurable by the user.  White is a sane
    # default, for now.
    color = 'ffffff'
    repository = get_working_repo(client, args.repository)
    try:
        repository.create_label(args.label, color)
    except GithubException as e:
        die('''Unable to create label %s.
The complete error response was:
%s
''' % (args.label, e.data))
    print('Label added.')
Beispiel #9
0
def do_list(client, args):
    """Command to list the issues for a given repository."""
    repository = get_working_repo(client, args.repository)
    status = args.status or 'open'
    issues = list(repository.get_issues(state=status))
    if not issues:
        print('%s has no %s issues' % (repository.full_name, status))
    else:
        print('%s has the following %s issues' %
              (repository.full_name, status))
        print('Issue# - Title')
    for issue in issues:
        print('%s - %s' % (issue.number, issue.title))
Beispiel #10
0
def addlabel(client, args):
    # xxx Make this configurable by the user.  White is a sane
    # default, for now.
    color = 'ffffff'
    repository = get_working_repo(client, args.repository)
    try:
        repository.create_label(args.label, color)
    except GithubException as e:
        die('''Unable to create label %s.
The complete error response was:
%s
''' % (args.label, e.data))
    print('Label added.')
Beispiel #11
0
def get_working_issue(client, args):
    """Get an object corresponding to the issue
    that the user wishes to manipulate.  Issues are identified by
    a repository name and issue number."""
    issue = None
    repository = get_working_repo(client, args.repository)
    try:
        issue_number = int(args.number)
    except ValueError:
        die("""%s is not a valid issue number.""" % args.number)
    try:
        issue = repository.get_issue(issue_number)
    except GithubException as e:
        die('Unable to fetch issue number %d for this repository: %s' % (issue_number, e.data['message']))
    return issue
Beispiel #12
0
def get_working_issue(client, args):
    """Get an object corresponding to the issue
    that the user wishes to manipulate.  Issues are identified by
    a repository name and issue number."""
    issue = None
    repository = get_working_repo(client, args.repository)
    try:
        issue_number = int(args.number)
    except ValueError:
        die("""%s is not a valid issue number.""" % args.number)
    try:
        issue = repository.get_issue(issue_number)
    except GithubException as e:
        die('Unable to fetch issue number %d for this repository: %s' %
            (issue_number, e.data['message']))
    return issue
Beispiel #13
0
def addlabel(client, args):
    issue = get_working_issue(client, args)
    repository = get_working_repo(client, args.repository)
    try:
        label = repository.get_label(args.label)
    except GithubException as e:
        if e.status == 404:
            die('''The label %s has not yet been added to this repository.
First, add it using:
cligh repo addlabel %s
''' % (args.label, args.label))
        else:
            die('''Unable to find the label %s in this repository.
Error message: %s
''' % (args.label, e.data['message']))

    issue.add_to_labels(label)
Beispiel #14
0
def addlabel(client, args):
    issue = get_working_issue(client, args)
    repository = get_working_repo(client, args.repository)
    try:
        label = repository.get_label(args.label)
    except GithubException as e:
        if e.status == 404:
            die('''The label %s has not yet been added to this repository.
First, add it using:
cligh repo addlabel %s
''' % (args.label, args.label))
        else:
            die('''Unable to find the label %s in this repository.
Error message: %s
''' % (args.label, e.data['message']))

    issue.add_to_labels(label)
Beispiel #15
0
def delete(client, args):
    """Delete a repository."""
    repository = get_working_repo(client, args.repository)
    repository.delete()
    print('Repository %s deleted.' % repository.full_name)
Beispiel #16
0
def delete(client, args):
    """Delete a repository."""
    repository = get_working_repo(client, args.repository)
    repository.delete()
    print('Repository %s deleted.' % repository.full_name)
Beispiel #17
0
def fork(client, args):
    """Fork a repository."""
    repo_to_fork = get_working_repo(client, args.repository)
    client.get_user().create_fork(repo_to_fork)
    print('Repository forked.')
Beispiel #18
0
def fork(client, args):
    """Fork a repository."""
    repo_to_fork = get_working_repo(client, args.repository)
    client.get_user().create_fork(repo_to_fork)
    print('Repository forked.')