当前位置: 首页 > news >正文

python 统计所有的 仓库 提交者的提交次数

字典去重 YYDS

在这里插入图片描述

然后再写入excel 表 yyds

#!/bin/env python3
from git.repo import Repo
import os
import pandas as pdspath = "/home/labstation/workqueue/sw"
url = "git@10.0.128.128"
date = [str(x) for x in range(202307, 202308)]
datefmt = "%Y%m"
counts = 0
AUTHORS = {}
AUTHORS_UNIQU = {}
DATE = {}
DATE_UNIQU = {}for proj in os.scandir(path):if not os.access(path + "/" + proj.name + "/.git", os.F_OK):continuerepo = Repo(path + "/" + proj.name)remoteUrl = repo.git.execute(["git", "remote", "-v"])if type(remoteUrl) is str:remoteUrl = map(lambda x: x.strip("\t"), remoteUrl.split("\n"))for checkUrl in remoteUrl:if checkUrl.find(url) > 0:continueres = repo.git.execute(["git", "branch", "-r"])if type(res) is str and len(res) != 0:branches = filter(lambda x: not x.startswith("origin/HEAD"),map(lambda x: x.strip(" "), res.split("\n")),)for it_branch in branches:for it in repo.iter_commits(it_branch):if it.authored_datetime.strftime(datefmt) in date:AUTHORS[str(it)] = it.author.nameDATE[str(it)] = (it_branch,proj.name,it.author.name,it.authored_datetime.strftime(datefmt),)for _it in AUTHORS:AUTHORS_UNIQU[AUTHORS[_it]] = 0for _it in AUTHORS_UNIQU:for _its in AUTHORS:if _it == AUTHORS[_its]:AUTHORS_UNIQU[_it] += 1for _it in DATE:DATE_UNIQU[DATE[_it]] = 0for _it in DATE_UNIQU:for _its in DATE:if _it == DATE[_its]:DATE_UNIQU[_it] += 1TotalExcel = {"姓名": [], "次数": []}for _it in AUTHORS_UNIQU:TotalExcel["姓名"].append(_it)TotalExcel["次数"].append(AUTHORS_UNIQU[_it])Excel = {"分支": [], "仓库名称": [], "提交者": [], "提交日期": [], "提交次数": []}
for it in DATE_UNIQU:Excel["分支"].append(it[0])Excel["仓库名称"].append(it[1])Excel["提交者"].append(it[2])Excel["提交日期"].append(it[3])Excel["提交次数"].append(DATE_UNIQU[it])writer = pds.ExcelWriter(date[0] + "~" + date[len(date) - 1] + ".xlsx")
excekWrute2 = pds.DataFrame(TotalExcel)
excekWrute2.to_excel(writer, sheet_name="统计总表")
execlWrite1 = pds.DataFrame(Excel)
execlWrite1.to_excel(writer, sheet_name="各仓库统计")
writer.close()

保存成excel 表格输出

YYDS … …

http://www.lryc.cn/news/104984.html

相关文章:

  • 018-从零搭建微服务-系统服务(五)
  • HarmonyOS 开发基础(三)登录页面单向数据绑定(父组件向子组件传参)
  • 发npm包
  • <el-empty>
  • IO流(4)- 序列化流与反序列化流
  • 人工智能如何应对 DevOps 监控和可观测性挑战
  • 数字化新时代,VR全景拍摄与制作
  • uniapp 权限说明
  • 3D Web轻量化渲染开发工具HOOPS Communicator是什么?
  • 心法利器[93] | 谈校招:技术面
  • excel英语翻译让你的数据更容易被理解
  • RK3588S之CPU--benchmark(二)
  • 入侵检查基础
  • JAVA开发工具-maven的安装与配置(最新最详细教程)
  • linux系统编程重点复习--进程的控制
  • 12-1_Qt 5.9 C++开发指南_自定义插件和库-自定义Widget组件(提升法(promotion)创建自定义定制化组件)
  • 【软件测试学习】—软件测试的基本认识(一)
  • Unity AI项目笔记
  • 如何在地图上寻找峨眉山零公里的龙洞湖
  • cloudstack平台host加入后,显示CPU speed为0GHz
  • 创新技术应用,提升企业图文档管理水平的新思路
  • 网络安全 Day22-mariadb数据库用户管理
  • SERDES关键技术
  • 小程序如何上传商品图片
  • vue中人员导出功能实现
  • 【微信小程序】引入第三方库poke对GZIP压缩数据进行解压
  • Pandas操作Excel
  • leetcode 712. Minimum ASCII Delete Sum for Two Strings(字符串删除字母的ASCII码之和)
  • Springboot -- 按照模板生成docx、pdf文件,docx转pdf格式
  • UE5.1.1 创建C++项目失败