我想从git提交日志中解析信息,数据格式如下(每个提交属于一个repo,每个repo可能包含多个提交)
如何获取每个部分信息(提交,作者,日期...)并保存到下面的图片中的字典?
http://i.stack.imgur.com/bUTtJ.png
有人可以帮助我吗?非常感谢
repo:device/sprd
commit 775ffdbcbd3e506b38fc5b57debc181e57d52654
Author: zhijie.yang <zhijie.yang@spreadtrum.com>
Date: Sun Feb 21 13:33:53 2016 +0800
Bug #532015 [new feature] EngineerMode add a SethRps switch
[root cause ] new features
[changes ] let EngineerMode can to write to /sys/class/net/seth_lte0/queues/rx-0/rps_cpus
[side effects] no
[self test ] <9832><follow bug steps,test 5 times,pass>
[reviewers ] jing.deng
[change_type ] feature
[tag_product ] common
Change-Id: Icaa1e5ec8f3eea7b7912bf59595e4b0884bf65e3
scx35l/init.sc8830_base.rc | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
repo:kernel
commit fc82a44b8965994fa2340832770169ce0242656f
Author: daniel.li <daniel.li@spreadtrum.com>
Date: Mon Feb 22 19:02:45 2016 +0800
Bug #524747 add otg function for sp9832a board
[root cause ] add otg function for iea board
[changes ] arch/arm/boot/dts/
[change_type ] bringup --> sprd_chip_support
[tag_product ] common
[side effects] no
[self test ] <sp9832a><adb pull/push ok, USB keypad OK>
[reviewers ] fei.zhang
Change-Id: Ie054e5e3c9c4c770a40eccf4b43500a666663023
.../boot/dts/sprd-scx35l_sp9832a_3h10_5mvolte.dts | 6 +++---
arch/arm/configs/sp9832a_3h10_5mvolte_defconfig | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
commit 35450fb6f5720b1f84698fc80d9df28035725a9d
Author: zhijie.yang <zhijie.yang@spreadtrum.com>
Date: Sun Feb 21 15:31:38 2016 +0800
Bug #532015 [new feature] EngineerMode add a SethRps switch
[root cause ] new features
[changes ] EngineerMode add a SethRps switch
[side effects] no
[self test ] <9832><follow bug steps,test 5 times,pass>
[reviewers ] jing.deng
[change_type ] feature
[tag_product ] common
Change-Id: I6fe8bb0e158617d8e1efefaed3b6d53b43eeef5e
res/values/strings.xml | 1 +
res/xml/pref_telephonytab.xml | 4 ++++
.../sprd/engineermode/BootCompletedReceiver.java | 1 +
.../engineermode/telephony/TelephonyFragment.java | 21 ++++++++++++++++++++
4 files changed, 27 insertions(+)
repo:vendor/sprd/modules/libcamera
commit 53ce0f9adcaeefa84f49ab49703ea3ed7463b980
Author: zhijie.yang <zhijie.yang@spreadtrum.com>
Date: Fri Feb 5 15:44:22 2016 +0800
Bug #524747 - [new feature] EngineerMode add a SethRps switch
[root cause ] new features
[changes ] EngineerMode add a SethRps switch
[side effects] no
[self test ] <9832><follow bug steps,test 5 times,pass>
[reviewers ] jing.deng
[change_type ] feature
[tag_product ] common
Change-Id: I173fe4e54d349ecc41200b72948cea8b02740e23
.../sp9832a_3h10_5mvolte/pinmap-sp9630-h100.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
答案 0 :(得分:0)
我说跳过解析原始文本格式 对于初学者来说,任何事情都很混乱,第二个原因是它比从支持git的库中获得预先格式化的结构更难。
尝试使用git模块:
from git import *
repo = Repo("sprd")
o = repo.remotes.origin
o.pull()
master = repo.head.reference
print master.log()
还要在信用到期时给予信用:git-python get commit feed from a repository