def get_commit_log(git_repo, viewvc_url, author_in_commit_body=False):
    repo = Repo(git_repo)
    log = repo.commits(config.EMAIL_GREP, search_body=author_in_commit_body)
    for commit in log[:]:
        if author_in_commit_body:
            name_match = re.search(
                '(Contributed|Patch) (from|by) [^<]*<{name_re}>'.format(name_re=config.EMAIL_RE),
                commit.body)
            if not name_match:
                review_match = re.search('R=.*{}'.format(config.EMAIL_RE), commit.body)
                if review_match:
                    # Skip stuff only reviewed
                    log.remove(commit)
                    continue
                raise Exception("Didn't find {} in commit msg ({})".format(config.EMAIL_RE, commit.body))
            commit.author = name_match.group('full_email')
            commit.stripped_author = name_match.group('name')
        else:
            name_match = re.match(config.EMAIL_RE, commit.author)
            if name_match:
                commit.stripped_author = name_match.group('name')
            else:
                commit.stripped_author = commit.author

        commit.viewvc = viewvc_url.format(rev=commit.sha)
    return log
def get_commit_log(git_repo, viewvc_url, author_in_commit_body=False):
    repo = Repo(git_repo)
    log = repo.commits(config.BODY_REGEX, search_body=author_in_commit_body)

    for commit in log[:]:
        author_match = re.search(config.AUTHOR_REGEX, commit.author)
        if author_match:
            commit.stripped_author = author_match.group('name')
        else:
            body_match = re.search(config.AUTHOR_REGEX, commit.body)
            if not body_match:
                raise Exception(
                    "Unable to determine original author of commit " +
                    commit.sha)
            guessed_author = body_match.group('name')
            commit.stripped_author = guessed_author

        commit.viewvc = viewvc_url.format(rev=commit.sha)
    return log
def get_commit_log(git_repo):
    is_v8 = 'v8' in git_repo
    repo = Repo(git_repo)
    log = repo.commits(is_v8)
    for commit in log:
        m = re.search(r'git-svn-id: ([^\s]+)', commit.body)
        if not m:
            # Found nothing!
            raise Exception("Didn't find git-svn-id in the commit body! Rev {0}"
                "".format(commit.sha))
        id = m.group(1)
        if is_v8:
            # e.g. https://v8.googlecode.com/svn/branches/bleeding_edge@18761
            m2 = re.match(r'https://v8.googlecode.com/svn/([^/]+)/[^@]*@(\d+)', id)
            m3 = re.search('(Contributed|Patch) (from|by) [^<]*<(?P<name>[^@]+)@opera\.com>',
                           commit.body)
            if not m3:
                raise Exception("Didn't find opera employee in commit msg ({})".format(commit.body))
            author = m3.group('name')
        else:
            # e.g. svn://svn.chromium.org/blink/trunk@165617
            m2 = re.match(r'svn://svn.chromium.org/([^/]+)/[^@]*@(\d+)', id)
            author = commit.author.replace('@opera.com', '')
        if not m2:
            # Found nothing!
            raise Exception("Didn't find product and revision in the svn URL! "
                "URL {0}, rev {1}.".format(id, commit.sha))
        commit.product = m2.group(1)
        commit.svn_revision = m2.group(2)
        if is_v8:
            commit.viewvc = (
                "https://code.google.com/p/v8/source/detail?r={rev}"
                .format(rev=commit.svn_revision)
            )
        else:
            commit.viewvc = (
                "http://src.chromium.org/viewvc/{prod}?revision={rev}&"
                "view=revision"
                .format(prod=commit.product, rev=commit.svn_revision)
            )

        commit.author_stripped = author
    return log
def get_commit_log(git_repo, viewvc_url, author_in_commit_body=False):
    repo = Repo(git_repo)
    log = repo.commits(config.BODY_REGEX, search_body=author_in_commit_body)

    for commit in log[:]:
        author_match = re.search(config.AUTHOR_REGEX, commit.author)
        if author_match:
            commit.stripped_author = author_match.group('name')
        else:
            body_match = re.search(config.AUTHOR_REGEX, commit.body)
            if not body_match:
                # Might be someone at Vewd calling themselves Opera by mistake
                # in the code review system. The regexps differ in that one
                # checks with <email> and the other do not so there is no
                # guarantee that both hits.
                continue
            guessed_author = body_match.group('name')
            commit.stripped_author = guessed_author

        commit.viewvc = viewvc_url.format(rev=commit.sha)
    return log
Esempio n. 5
0
def get_commit_log(git_repo, viewvc_url, author_in_commit_body=False):
    repo = Repo(git_repo)
    log = repo.commits(config.BODY_REGEX, search_body=author_in_commit_body)

    for commit in log[:]:
        author_match = re.search(config.AUTHOR_REGEX, commit.author)
        if author_match:
            commit.stripped_author = author_match.group('name')
        else:
            body_match = re.search(config.AUTHOR_REGEX, commit.body)
            if not body_match:
                # Might be someone at Vewd calling themselves Opera by mistake
                # in the code review system. The regexps differ in that one
                # checks with <email> and the other do not so there is no
                # guarantee that both hits.
                continue
            guessed_author = body_match.group('name')
            commit.stripped_author = guessed_author

        commit.viewvc = viewvc_url.format(rev=commit.sha)
    return log