コード例 #1
0
ファイル: find_commits.py プロジェクト: jhford/uplift
def guess_from_comments(repo_dir, upstream, comments):
    commits = {}
    pull_requests = []
    for c in comments:
        if not c.has_key('text') or c.get('text', None) == None or c.get('text', '') == '':
            continue
        for r in commit_regex:
            c_txt = c['text']
            matches = r.finditer(c_txt)
            for m in matches:
                d = m.groupdict()
                if d.has_key('id'):
                    commit_id = d['id']
                    if git.git_object_type(repo_dir, commit_id) == 'commit':
                        if git.get_rev(repo_dir, commit_id) and git.commit_on_branch(repo_dir, commit_id, upstream):
                            if not commits.has_key(commit_id):
                                commits[commit_id] = []
                            # The reason should include the person's real name!
                            reason = "%s made a comment which matched the pattern %s:\n%s\n%s" % (
                                c['creator']['name'], r.pattern, "-"*80, c_txt)

                            commits[commit_id].append(reason)
                elif d.has_key('pr'):
                    try:
                        pr_num = int(d['pr'], 10)
                    except ValueError:
                        pass

                    if not pr_num in pull_requests:
                        pull_requests.append(pr_num)

    for pr_num in pull_requests:
        guess_from_pr(repo_dir, upstream, pr_num)
    return commits
コード例 #2
0
ファイル: find_commits.py プロジェクト: jhford/uplift
def add_commit(repo_dir, upstream, commits, commit):
    if not git.valid_id(commit):
        print "This sha1 is not a valid commit id: %s" % commit
        return

    try:
        on_branch = git.commit_on_branch(repo_dir, commit, upstream)
    except:
        on_branch = False

    if not on_branch:
        print "Commit %s is not on upstream branch '%s'" % (commit, upstream)
        return

    try:
        full_rev = git.get_rev(repo_dir, id=commit)
    except git.GitError, e:
        full_rev = None