首页 > 解决方案 > 在单独的行中创建提交、作者、时间戳、文件日志的列

问题描述

我有一个 git 日志,其中提交哈希、作者、时间戳、提交消息和文件日志(在行的情况下是动态的)在单独的行中。我可以单独提取数据(但不能提取文件日志和消息)但不能创建列。

这是示例文件

commit 2232asdfeafdadssc0a63d3ded7e95e894bb735c121f
Author: John Shahi
Date:   Thu Jun 10 05:10:31 2021 +0000

    Feature/bill overview

70    0    src/components/pages/abc.tsx


commit 18asdfasd9104c7fb59d9027f48csdfss8b61776e21d0
Author: rashi.coder
Date:   Wed Jun 9 12:39:33 2021 +0545

    disable other call, refine disabled styles

13    1    src/components/organisms/contact/detail/card/ContactDetailCard.tsx
11    2    src/components/organisms/contact/list/ActionsColumn.tsx

commit 65adfadfc2090e299bf9c514735eb1a2779a12ed9
Author: Ritesh  Poudel
Date:   Wed Jun 9 05:08:00 2021 +0000

commit 04afdad56f5136da10c87d5181dab8afdsfs29e57a5
Author: rashi.coder
Date:   Wed Jun 9 10:22:29 2021 +0545

    fix multiple contacts selection overflow

1    0    src/components/organisms/contact/list/ContactTable.tsx
8    1    src/components/organisms/contact/list/Styles.tsx

这就是我试图做的

commits = pd.read_csv(
        COMMIT_LOG,
        sep="\n",
        header=None,
        names=["raw"]
        # names=[
        #     "sha",
        #     "author",
        #     "timestamp",
        #     "message",
        #     "additions",
        #     "deletions",
        #     "filename",
        # ],
    )
    commit_marker = commits[commits["raw"].str.startswith("commit")]
    author_marker = commits[commits["raw"].str.startswith("Author")]
    date_marker = commits[commits["raw"].str.startswith("Date:")]
    print(commit_marker.head())
    print(author_marker.head())
    print(date_marker.head())

标签: pythonpandas

解决方案


推荐阅读