def manage_old_issue(repo_username, repo_id, issue): # disable auto closing issues return if not issue: return number = issue.get('number') if not number: return if is_closed(issue): return if is_pull_request(issue): return updated_str = issue.get('updated_at') if not updated_str: return updated_at = util.get_date(updated_str) if not is_old_issue(updated_at): return if has_labels_preventing_close(issue): return if has_comments_preventing_close(issue): return if has_assignee_preventing_close(issue): return if has_milestone_preventing_close(issue): return if github_api.is_org_member(repo_username, issue['user']['login']): return if cvar['DO_NOT_CLOSE_WHEN_REFERENCED'] is False: issue_events = github_api.fetch_issue_events(repo_username, repo_id, number) if has_events_preventing_close(issue_events): return return close_old_issue(repo_username, repo_id, number, issue)
def manage_needs_reply_issue(repo_username, repo_id, issue): if not issue: return number = issue.get('number') if not number: return if not has_needs_reply_label(issue): return issue_events = github_api.fetch_issue_events(repo_username, repo_id, number) if not issue_events or not isinstance(issue_events, list): return need_reply_label_added = get_most_recent_datetime_need_reply_label_added(issue_events) if not need_reply_label_added: return issue_comments = github_api.fetch_issue_comments(repo_username, repo_id, number) if not issue_comments or not isinstance(issue_comments, list): return most_recent_response = get_most_recent_datetime_creator_response(issue, issue_comments) if not most_recent_response: return print 'Needs reply: %s, label added: %s, most recent response: %s' % (number, need_reply_label_added, most_recent_response) if has_replied_since_adding_label(need_reply_label_added, most_recent_response): print 'has_replied_since_adding_label, removing label: %s' % number return remove_needs_reply_label(repo_username, repo_id, number, issue) if not has_replied_in_timely_manner(need_reply_label_added): print 'not has_replied_in_timely_manner, closing issue: %s' % number return close_needs_reply_issue(repo_username, repo_id, number)