Ejemplo n.º 1
0
def display_uplift_report(report, max_summary=90):
    """Generate a PrettyTable that shows the bug id, branch status
    and first up to 100 chars of the summary"""
    branches = c.read_value('repository.enabled_branches')
    headers = ['Bug'] + ['%s commit' % x for x in ['master'] + branches] + ['Summary']
    t = pt.PrettyTable(headers, sortby="Bug")
    t.align['Bug'] = "l"
    t.align['Summary'] = "l"
    for bug_id in [x for x in report.keys() if not uplift.is_skipable(x)]:
        bug = report[bug_id]
        row = [bug_id]
        master_commits = bug['commits']
        row.append("\n".join([x[:7] for x in master_commits]) if len(master_commits) > 0 else "skipped")
        for branch in branches:
            branch_commits = []
            for mcommit in master_commits:
                if bug.has_key('uplift_status'):
                    if branch in bug['uplift_status'][mcommit]['success'].keys():
                        branch_commit = bug['uplift_status'][mcommit]['success'][branch]
                        if branch_commit == mcommit:
                            branch_commits.append("+++")
                        else:
                            branch_commits.append(branch_commit)
                    elif branch in bug['uplift_status'][mcommit]['failure']:
                        branch_commits.append("failed")
                    else:
                        branch_commits.append("---")
            if len(branch_commits) == 0:
                row.append("---")
            else:
                row.append("\n".join([x[:7] for x in branch_commits]))


        t.add_row(row + [trim_words(bug['summary'])])
    return t
Ejemplo n.º 2
0
def for_all_bugs(repo_dir, requirements, upstream="master"):
    # Let's see if we have any commits in the req file.
    any_bug_has_commits = False
    bugs_without_commits = []
    for bug_id in requirements:
        if requirements[bug_id].has_key('commits'):
            if len(requirements[bug_id]['commits']) > 0:
                any_bug_has_commits = True
        else:
            bugs_without_commits.append(bug_id)

    if any_bug_has_commits:
        print "Some bugs in this requirements file already have commits."
        # reuse is use the existing commits, don't ask for more.
        # add is use the existing commits for bugs that have no commits, ignore others
        # delete will remove the commits from the requirements dictionary
        prompt = "Enter 'reuse', 'add' or 'delete': "
        user_input = raw_input(prompt).strip()
        while user_input not in ('reuse', 'add', 'delete'):
            user_input = raw_input(prompt).strip()
        
        if user_input == 'reuse':
            bugs_to_find = [] # just use what's in the file
        elif user_input == 'add':
            bugs_to_find = bugs_without_commits # Only ask for commits for commit-less bugs
        elif user_input == 'delete':
            # Delete the commits that are in the requirements file
            for bug_id in requirements.keys():
                if requirements[bug_id].has_key('commits'):
                    del requirements[bug_id]['commits']
            util.write_json(uplift.requirements_file, requirements)
            bugs_to_find = requirements.keys()
        else:
            raise Exception("Huh?")
    else:
        bugs_to_find = requirements.keys()

    pruned_bugs_to_find = [x for x in bugs_to_find if not uplift.is_skipable(x)]
    j=0
    for bug_id in sorted(pruned_bugs_to_find):
        j+=1
        print "=" * 80
        print "Bug %d of %d" % (j, len(pruned_bugs_to_find))
        bug = bzapi.fetch_complete_bug(bug_id, cache_ok=True)
        requirements[bug_id]['commits'] = for_one_bug(repo_dir, bug_id, bug, upstream)
        util.write_json(uplift.requirements_file, requirements)
    return requirements
Ejemplo n.º 3
0
def display_uplift_requirements(requirements, max_summary=90):
    """Generate a PrettyTable that shows the bug id, branch status
    and first up to 100 chars of the summary"""
    branches = c.read_value('repository.enabled_branches')
    headers = ['Bug'] + ['%s status' % x for x in branches] + ['Summary']
    t = pt.PrettyTable(headers, sortby="Bug")
    t.align['Bug'] = "l"
    t.align['Summary'] = "l"
    for bug_id in [x for x in requirements.keys() if not uplift.is_skipable(x)]:
        bug = requirements[bug_id]
        row = [bug_id]
        needed_on = bug['needed_on']
        fixed_on = bug['already_fixed_on']
        for branch in branches:
            if branch in fixed_on:
                row.append("fixed")
            elif branch in needed_on:
                row.append("needed")
            else:
                row.append("---")

        t.add_row(row + [trim_words(bug['summary'])])
    return t