Exemplo n.º 1
0
def check_for_invalid_card_names(issue: Issue, cards: List[str]) -> None:
    labels = [lab.name for lab in issue.labels]
    fail = False
    for c in cards:
        if '//' in c:
            pass
        elif not c in cardnames():
            fail = True
    if fail and not 'Invalid Card Name' in labels:
        issue.add_to_labels('Invalid Card Name')
    elif not fail and 'Invalid Card Name' in labels:
        issue.remove_from_labels('Invalid Card Name')
Exemplo n.º 2
0
def apply_screenshot_labels(issue: Issue) -> None:
    labels = [c.name for c in issue.labels]
    has_screenshot = 'Has Screenshot' in labels
    has_video = 'Has Video' in labels

    if '(https://user-images.githubusercontent.com/' in issue.body:
        has_screenshot = True
    if 'https://imgur.com/' in issue.body:
        has_screenshot = True
    if 'https://i.imgur.com' in issue.body:
        has_screenshot = True
    if 'https://youtu.be/' in issue.body:
        has_video = True
    if 'youtube.com/watch' in issue.body:
        has_video = True
    if 'clips.twitch.tv/' in issue.body:
        has_video = True

    if has_screenshot and not 'Has Screenshot' in labels:
        issue.add_to_labels('Has Screenshot')
    if has_screenshot and 'Needs Screenshot' in labels:
        issue.remove_from_labels('Needs Screenshot')

    if has_video and not 'Has Video' in labels:
        issue.add_to_labels('Has Video')
    if has_video and 'Needs Video' in labels:
        issue.remove_from_labels('Needs Video')
    if has_video and 'Needs Screenshot' in labels:
        issue.remove_from_labels('Needs Screenshot')

    if not has_screenshot and not has_video and not 'Needs Screenshot' in labels:
        issue.add_to_labels('Needs Screenshot')
    if has_screenshot and not has_video and not 'Needs Video' in labels:
        issue.add_to_labels('Needs Video')
Exemplo n.º 3
0
def process_issue(issue: Issue) -> None:
    age = (datetime.datetime.now() - issue.updated_at).days
    if age < 5:
        fix_user_errors(issue)
        apply_screenshot_labels(issue)
    labels = [c.name for c in issue.labels]
    see_also = strings.get_body_field(issue.body, 'See Also')
    cards = get_affects(issue)

    if age < 5:
        check_for_invalid_card_names(issue, cards)
        update_issue_body(issue, cards, see_also)

    pd_legal = ([True for c in cards if c in pd_legal_cards()] or [False])[0]

    if pd_legal and not 'Affects PD' in labels:
        issue.add_to_labels('Affects PD')
    elif not pd_legal and 'Affects PD' in labels:
        issue.remove_from_labels('Affects PD')

    msg = issue.title

    categories = [c for c in labels if c in CATEGORIES]
    if not categories:
        if 'From Bug Blog' in labels:
            cat = 'Unclassified'
        else:
            cat = 'Unconfirmed'
            if not issue.comments:
                print(
                    'Issue #{id} was reported {days} ago, and has had no followup.'
                    .format(id=issue.number, days=age))
                if age > 30:
                    issue.create_comment('Closing due to lack of followup.')
                    issue.edit(state='closed')
                    return

        if not 'Unclassified' in labels:
            issue.add_to_labels('Unclassified')
    elif 'Unclassified' in labels:
        print('Removing Unclassified from Issue #{id}'.format(id=issue.number))
        issue.remove_from_labels('Unclassified')
        cat = categories.pop()
    else:
        cat = categories.pop()

    for card in cards:
        bannable = cat in BADCATS and 'Multiplayer' not in labels
        bug = {
            'card': card,
            'description': msg,
            'category': cat,
            'last_updated': str(issue.updated_at),
            'pd_legal': card in pd_legal_cards(),
            'bug_blog': 'From Bug Blog' in labels,
            'breaking': cat in BADCATS,
            'bannable': bannable,
            'url': issue.html_url,
        }
        if 'Multiplayer' in labels:
            bug['multiplayer_only'] = True
        if 'Collection' in labels:
            bug['cade_bug'] = True
        if 'Deck Building' in labels:
            bug['cade_bug'] = True

        age = datetime.datetime.now() - issue.updated_at
        if 'Help Wanted' in labels:
            bug['help_wanted'] = True
        elif age.days > 60:
            bug['help_wanted'] = True

        bug['last_verified'] = VERIFICATION_BY_ISSUE.get(issue.number, None)

        ALL_BUGS.append(bug)