view contrib/gcc-changelog/ @ 19:2b5abeee2509 default tip

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
line wrap: on
line source

#!/usr/bin/env python3
# This file is part of GCC.
# GCC is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3, or (at your option) any later
# version.
# GCC is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# You should have received a copy of the GNU General Public License
# along with GCC; see the file COPYING3.  If not see
# <>.  */

from datetime import datetime

    from git import Repo
except ImportError:
    print('Cannot import GitPython package, please install the package:')
    print('  Fedora, openSUSE: python3-GitPython')
    print('  Debian, Ubuntu: python3-git')

from git_commit import GitCommit

def parse_git_revisions(repo_path, revisions, strict=False):
    repo = Repo(repo_path)

    parsed_commits = []
    if '..' in revisions:
        commits = list(repo.iter_commits(revisions))
        commits = [repo.commit(revisions)]

    for commit in commits:
        diff = repo.commit(commit.hexsha + '~').diff(commit.hexsha)

        modified_files = []
        for file in diff:
            if file.new_file:
                t = 'A'
            elif file.deleted_file:
                t = 'D'
                t = 'M'
            modified_files.append((file.b_path, t))

        date = datetime.utcfromtimestamp(commit.committed_date)
        author = '%s  <%s>' % (,
        git_commit = GitCommit(commit.hexsha, date, author,
                               commit.message.split('\n'), modified_files,
    return parsed_commits