示例#1
0
文件: uplift.py 项目: jhford/uplift
def build_uplift_requirements(repo_dir):
    if os.path.exists(requirements_file) and util.ask_yn("Found existing requirements. Should they be used?"):
        bug_info = util.read_json(requirements_file)
    else:
        bug_info = {}
        enabled_branches = c.read_value('repository.enabled_branches')
        all_queries = c.read_value('queries')
        queries = []
        for branch in enabled_branches:
            queries.extend(all_queries[branch])

        bugs = [x for x in find_bugs(queries) if not is_skipable(x)]
        print "Fetching bug data"
        for bug_id in bugs:
            if is_skipable(bug_id):
                continue
            bug = bzapi.fetch_complete_bug(bug_id)
            print "+",
            needed_on = branch_logic.needed_on_branches(bug)
            if len(needed_on) == 0:
                continue
            b = bug_info[bug_id] = {}
            b['needed_on'] = needed_on
            b['already_fixed_on'] = branch_logic.fixed_on_branches(bug)
            b['summary'] = bug['summary']
        print "\nFinished fetching bug data"
        util.write_json(requirements_file, bug_info)
    return bug_info
示例#2
0
def ugly_bug_comment(repo_dir, bug_id, bug):
    values = bug['flags_to_set']
    bug_data = bzapi.fetch_complete_bug(bug_id, cache_ok=True)
    flags = make_needinfo(bug_data)

    comment = generate_ugly_bug_msg(bug)

    try:
        bzapi.update_bug(bug_id, comment=comment, values=values, flags=flags)
    except Exception, e:
        raise FailedToComment({
            'exception': e,
            'traceback': traceback.format_exc()
        })
示例#3
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
示例#4
0
def bad_bug_comment(repo_dir, bug_id, bug):
    # Short circuit for when we don't need to make a comment
    bug_data = bzapi.fetch_complete_bug(bug_id, cache_ok=True)
    for c in [x['text'] for x in bug_data['comments']]:
        if c and 'git cherry-pick' in c:
            return

    # If there is an assignee, try to needinfo them!
    flags = make_needinfo(bug_data)

    comment = generate_bad_bug_msg(repo_dir, bug)

    try:
        bzapi.update_bug(bug_id, comment=comment, values={}, flags=flags)
    except Exception, e:
        raise FailedToComment({
            'exception': e,
            'traceback': traceback.format_exc()
        })