python读取git日志_使用python分析git log日志示例

本文介绍了如何使用Python脚本来读取和分析Git日志,特别是针对特定日期范围和关键词进行搜索。通过示例代码展示了如何获取日志、处理分支、解析日志行并输出到文件的过程。
摘要由CSDN通过智能技术生成

# -*- coding: utf-8 -*-

# created by vince67 Feb.2014

# [email protected]

import re

import os

import subprocess

def run(project_dir, date_from, date_to, search_key, filename):

bug_dic = {}

bug_branch_dic = {}

try:

os.chdir(project_dir)

except Exception, e:

raise e

branches_list = []

branches_list = get_branches()

for branch in branches_list:

bug_branch_dic = deal_branch(date_from,

date_to,

branch,

search_key)

for item in bug_branch_dic:

if item not in bug_dic:

bug_dic[item] = bug_branch_dic[item]

else:

bug_dic[item] += bug_branch_dic[item]

log_output(filename, bug_dic)

# abstract log of one branch

def deal_branch(date_from, date_to, branch, search_key):

try:

os.sy

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值