-
2019-12-14 22:23:18
总体思路
git log --date=iso --pretty=format:'{"commit": "%h","author": "%aN <%aE>","date": "%ad","message": "%s"},' > z:/log.txt
可以把日志以json格式重定向到log.txt
然后分析可以用solr来处理
通过以上的log.txt不能让计算机去自动处理,因为人提交的message信息里面不可信,啥都有,用json也无法处理,所以需要更改方案。
需要先通过以上命令的commit信息也就是commitid来获取具体的message信息
而通过commitid也可以获取到该commitid出现的所有分支
通过commit id获取具体提交的信息
git log -1 268c548726fcab3ebdab19a70713b269038e4d05
其中-1是数字表示一条,-1的空格后面是具体的commit id。
对这个命令再次优化增加--pretty参数可以只输出此次commit id对应的提交信息
git log -1 e27c4b483792d8009c666b36f849f5415c5c1357 --pretty=format:'%s'
java中调用git命令
方法有2种,一个是直接执行还有一个是eclipse的jgit,初步确定选用eclipse的jgit,直接执行牵扯事宜比较多。
更多相关内容 -
GitAnalysis:一个通用的git日志分析程序,用于比较多个项目与子项目之间的git活动
2021-06-14 14:51:32GitAnalysis 是一个通用的 git 日志分析程序,用于比较多个项目与子项目之间的 git 活动。 最初编写这个程序是为了比较各种开源 IaaS 项目的活跃度,包括 CloudStack、Eucalyptus、OpenNebula 和 OpenStack。 但是,... -
gitfinery:gitfinery是git日志分析器,可让您对项目进行更深入的了解
2021-02-01 13:53:28Gitfinery 核心 git驱动 API提供者 索引器?! 服务 变更频率清单 其他名单 每个目标的其他列表 -
使用python分析git log日志示例
2020-12-17 14:41:29branch(date_from, date_to, branch, search_key): try: os.system(‘git checkout ‘ + branch) os.system(‘git pull ‘) except Exception, error: print error cmd_git_log = ["git", "log", "--stat", "--no-...# -*- 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.system(‘git checkout ‘ + branch)
os.system(‘git pull ‘)
except Exception, error:
print error
cmd_git_log = ["git",
"log",
"--stat",
"--no-merges",
"-m",
"--after="+date_from,
"--before="+date_to]
proc = subprocess.Popen(cmd_git_log,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
bug_branch_dic = deal_lines(date_from,
date_to,
search_key,
stdout)
return bug_branch_dic
# write commits log to file
def log_output(filename, bug_dic):
fi = open(filename, ‘w‘)
for item in bug_dic:
m1 = ‘--‘*5 + ‘BUG:‘ + item + ‘--‘*20 + ‘\n‘
fi.write(m1)
for commit in bug_dic[item]:
fi.write(commit)
fi.close()
# analyze log
def deal_lines(date_from, date_to, search_key, stdout):
bug_dic = {}
for line in stdout.split(‘commit ‘):
if re.search(‘Bug: \d+‘, line) is not None and re.search(search_key, line) is not None:
bug_id = line.split(‘Bug: ‘)[1].split(‘\n‘)[0]
if bug_id not in bug_dic:
bug_dic[bug_id] = [line]
else:
bug_dic[bug_id] += [line]
return bug_dic
# get all branches of a project
def get_branches():
branch_list = []
branches = []
tmp_str = ‘‘
try:
cmd_git_remote = ‘git remote show origin‘
proc = subprocess.Popen(cmd_git_remote.split(),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
tmp_str = stdout.split(‘Local branches configured‘)[0]
try:
tmp_str = tmp_str.split(‘Remote branches:\n‘)[1]
except:
tmp_str = tmp_str.split(‘Remote branch:\n‘)[1]
branches = tmp_str.split(‘\n‘)
for branch in branches[0:-1]:
if re.search(‘ tracked‘, branch) is not None:
branch = branch.replace(‘tracked‘, ‘‘).strip(‘ ‘)
branch_list.append(branch)
except Exception, error:
if branch_list == []:
print "Can not get any branch!"
return branch_list
if __name__ == ‘__main__‘:
# path of the .git project. example: "/home/username/projects/jekyll_vincent"
project_dir = ""
date_from = "2014-01-25"
date_to = "2014-02-26"
# only search ‘Bug: \d+‘ for default
search_key = ""
# name of output file. example:"/home/username/jekyll_0125_0226.log"
filename = ""
run(project_dir, date_from, date_to, search_key, filename)
-
Python实现一个Git日志统计分析的小工具
2020-09-20 23:45:21主要给大家介绍了关于利用Python如何实现一个Git日志统计分析小工具的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧。 -
git2json:将git日志转换为JSON以便于分析
2021-02-22 01:15:16将git日志转换为JSON,以便于分析。 免费软件:BSD许可证 文档: : 。 安装 安装git2json的最简单方法是通过pip: pip install git2json 如果您需要最新版本(遇到错误的风险更大),可以克隆此存储库并手动安装... -
grunt-git-log-json:Grunt任务以json格式写入git日志
2021-05-26 12:41:37这个grunt插件将分析git log的输出,并生成一个JSON格式的数据结构,列出每个标签的所有提交。 为此,标签需要使用。 入门 该插件需要Grunt。 如果您以前从未使用过 ,请务必查看《指南》,因为它说明了如何创建... -
Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-07-git安装与身份设置.mp4
2022-06-02 16:34:35Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-07-git安装与身份 -
Git之提交日志规范
2020-08-24 12:20:38Git进行commit时都需要提交说明(commit message): Git commit -m 'hello world' -m参数就是用来指定commit message的 commit message应该清晰明了,说明本次提交的目的。 2 Commit message的格式 Commit message...1 介绍
Git进行commit时都需要提交说明(commit message):
Git commit -m 'hello world'
-m
参数就是用来指定commit message的commit message应该清晰明了,说明本次提交的目的。
2 Commit message的格式
Commit message应该包括三个部分:Header/Body/Footer。其中,Header是必需的,Body和Footer可以省略。
<type>(<scope>): <subject> // 空一行 <body> // 空一行 <footer>
不管是哪一个部分,任何一行都不得超过72个字符(或100个字符)。这是为了避免自动换行影响美观。
2.1 Header
只有一行,包含三个字段,
type(必须)、scope(可选)和subject(必须)
(1)type
用于说明commit的类别,只允许使用一下7个标识:- feat:新功能(feature)
- fix:修补bug
- docs:文档(documentation)
- style:格式(不影响代码运行的改动)
- refactor:重构(即不是新增功能,也不是修改bug的代码变动)
- test:增加测试
- chore:构建过程或辅助工具的变动
(2)scope
用于说明commit影响的范围,比如数据层、控制层、视图层等,是项目不同而不同(3)subject
是commit的简短描述,不超过50字符例如fix: array parsing issue when multiple spaces were contained in string.
- 义动词开头,使用第一人称现在时(change,而不是changed)
- 第一个字母小写
- 结尾不加句号(.)
2.2 Body
是对本次commit的详细描述,可以分成多行:
More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. Further paragraphs come after blank lines. - Bullet points are okay, too - Use a hanging indent
有两个注意点:
- 使用第一人称现在时
- 说明代码变动的动机,以及与以前行为的对比
2.3 Footer
只是用与两种情况
(1) 不兼容变动
如果当前代码与上一个版本不兼容,则Footer部分以BREAKING CHANGE开头,后面是变动的描述以及变动理由和迁移方法
BREAKING CHANGE: isolate scope bindings definition has changed.To migrate the code follow the example below: Before: scope: { myAttr: 'attribute', } After: scope: { myAttr: '@', } The removed `inject` wasn't generaly useful for directives so there should be no code using it.
(2)关闭Issue
如果当前commit针对某个issue,那么可以在Footer部分关闭这个issueCloses #123, #245, #992
2.4 Revert
有一种特殊情况,如果当前commit用于撤销以前的commit,则必须以revert:开头,后面跟着被撤销的Commit的Header
revert: feat(pencil): add 'graphiteWidth' option This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
Body部分的格式是固定的,必须写成·This reverts commit ·
Commitizen
一个撰写合格的Commit message的工具
安装:
npm install -g commitizen
然后,在项目目录里,运行下面的命令,使其支持 Angular 的 Commit message 格式。
commitizen init cz-conventional-changelog --save --save-exact
以后凡是用到
git commit
的命令,一律改为git cz
,这时,就会出现选项,用来生成符合格式的Commit message。validate-commit-msg
用于检查Node项目的Commit message是否符合格式,需要手动安装
首先拷贝这个JS文件到代码库,命名为
validate-commit-msg.js
然后把这个脚本加入Git的Hook,在
package.json
中使用ghooks,把这个脚本加为commit-msg
时运行"config": { "ghooks": { "commit-msg": "./validate-commit-msg.js" } }
然后每次
Git commit
时脚本就会自动检查Commit message是否合格,不合格就会报错简单的示例
feat: 新增分析师清理功能
分析师清理功能,包括
- 查询分析师
- 分时段清理
feat: 新增分析师清理功能 分析师清理功能,包括 1. 查询分析师 2. 分时段清理
不包含正文的提交说明
docs: correct spelling of CHANGELOG
包含作用域的提交说明
feat(lang): added polish language
为fix编写的提交说明,包含可选的issue编号
fix: minor typos in code see the issue for details on the typos fixed fixes issue #12
为什么使用约定式提交Commit message
- 自动化生成 CHANGELOG。
- 基于提交的类型,自动决定语义化的版本变更。
- 向同事、公众与其他利益关系人传达变化的性质。
- 触发构建和部署流程。
- 让人们更容易地探索结构化的提交历史,降低贡献项目的难度。
原作参考:
http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html
本文转载自:
https://blog.csdn.net/duola8789/article/details/80493926 -
Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-08-创建本地git仓库-提交第1.mp4
2022-05-28 18:37:16Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-08-创建本地git仓库-提 -
Git代码提交,固定日志模板
2022-01-12 19:54:33通过配置服务器的 Git 提交日志,就可以实现统一的代码提交风格。 先看实现效果,如下图 这样大家就必须按照现有的模板,填写对应内容,保持整体格式的统一。 Git 有提供一个示例文件,路径: .git/hooks/prepare-...时间:2022年1月9日21:38:22
团队开发,但是每个人的日志风格不同该怎么办?
通过配置服务器的 Git 提交日志,就可以实现统一的代码提交风格。
先看实现效果,如下图
这样大家就必须按照现有的模板,填写对应内容,保持整体格式的统一。
Git 有提供一个示例文件,路径:
.git/hooks/prepare-commit-msg.sample
查看文件内容,全是英文的,如下
zhaoc@ubuntu2004:~/09-GitRepository/TheCProgrammingLanguage/part-1/1-6$ cat ../../.git/hooks/prepare-commit-msg.sample #!/bin/sh # # An example hook script to prepare the commit log message. # Called by "git commit" with the name of the file that has the # commit message, followed by the description of the commit # message's source. The hook's purpose is to edit the commit # message file. If the hook fails with a non-zero status, # the commit is aborted. # # To enable this hook, rename this file to "prepare-commit-msg". # This hook includes three examples. The first one removes the # "# Please enter the commit message..." help message. # # The second includes the output of "git diff --name-status -r" # into the message, just before the "git status" output. It is # commented because it doesn't cope with --amend or with squashed # commits. # # The third example adds a Signed-off-by line to the message, that can # still be edited. This is rarely a good idea. COMMIT_MSG_FILE=$1 COMMIT_SOURCE=$2 SHA1=$3 /usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" # case "$COMMIT_SOURCE,$SHA1" in # ,|template,) # /usr/bin/perl -i.bak -pe ' # print "\n" . `git diff --cached --name-status -r` # if /^#/ && $first++ == 0' "$COMMIT_MSG_FILE" ;; # *) ;; # esac # SOB=$(git var GIT_COMMITTER_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') # git interpret-trailers --in-place --trailer "$SOB" "$COMMIT_MSG_FILE" # if test -z "$COMMIT_SOURCE" # then # /usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE" # fi
文件最下边给出了两个示例,我们要用到的重点是这条语句
/usr/bin/perl -i.bak -pe 'print "\n" if !$first_line++' "$COMMIT_MSG_FILE"
接下来修改自己的配置文件,复制原有的示例文件,命名为
prepare-commit-msg
,注意不带后缀!cp .git/hooks/prepare-commit-msg.sample .git/hooks/prepare-commit-msg
修改
prepare-commit-msg
文件,直接屏蔽原代码语句,参考如下格式:COMMIT_MSG_FILE=$1 COMMIT_SOURCE=$2 SHA1=$3 #/usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE" case "$2,$3" in merge,) /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; ,|template,) /usr/bin/perl -i.bak -pe 'print "修改描述:\n影响分析:\n是否自测:\n自测内容:\n测试建议:\n代码审查:\nNOTE:\n" if /^#/ && $first++ == 0' "$1" ;; *) ;; esac
修改完毕,先保存,再退出!
然后进行代码提交的测试即可,参考命令如下:
# 添加所有修改文件到缓存区(待提交区) git add . # 提交代码,并填写日志; # 这一步会显示之前编写好的日志文件 git commit # 填写完日志后,推送到服务器就可以啦 git push
好啦,我是小二,我们下期见~
-
Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-17-分支管理.mp4
2022-06-02 16:38:38Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-17-分支管理.mp4 -
git log 日志导出 以及参数配置
2021-11-04 10:55:05导出日志到文件: git log --pretty=format:"%ai,%an:%s" --since="100 day ago" >> ~/Desktop/commit.log git log --date=iso --pretty=format:'"%h","%an","%ad","%s"' >> ~/Desktop/commit.csv git... -
Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-12-撤消回退.mp4
2022-05-28 18:44:55Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-12-撤消回退.mp4 -
Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-11-阶段小结.mp4
2022-05-28 18:42:23Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-11-阶段小结.mp4 -
Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-13-三大区深入理解.mp4
2022-06-02 16:36:38Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-13-三大区深入理解 -
git解析日志常用命令
2019-01-07 10:48:00git diff --name-only ORIG_HEAD ...查看日志列表 git diff 每次提交时显示差异变化 git diff --stat 每次提交时显示差异变化列表 git log -p 查看每个提交引入的实际更改。 git shortlog 按作者对每个提交进行... -
git 使用一点通 log 日志部分
2021-10-18 13:52:23名词解释: origin:远程仓库并默认以 “origin” 为简写 origin 仓库名称 master:分支名称 Git 基础 - 查看提交历史 ... 你也可以限制显示的日志条目数量,例如使用-2选项来只显示最近的... -
Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-10-查看提交历史与版本回退.mp4
2022-05-28 18:39:50Linux运维-04-日志分析-日志监控ELK-day03-生产案例及Git版本控制-10-查看提交历史与版 -
git log 查看提交日志
2020-12-24 09:01:54git log 查看日志 $ git log commit 0aa4a7e5e8f9bf63e62c3239a1256a5a5610a6cf (HEAD -> xj4.4.1-r-1.3.0, origin/province/xinjiangV4-4-1/release/V1-3-0) Merge: 41f230f 4d83019 Author: 徐景建 <徐... -
python解析git log后生成页面显示git更新日志信息
2020-12-07 10:58:48使用git log可以查到git上项目的更新日志。如下两个git项目,我想把git的日志信息解析成一个便于在浏览器上查看的页面。https://github.com/gityf/luahttps://github.com/gityf/db使用git log命令获取git更新日志... -
IDEA git commit记录分析
2022-01-29 17:18:32分析 idea中黄色标签代表 HEAD,绿色表示的是你本地分支,紫色是远程分支(如果只有紫色没有绿色,说明你本地没有该分支) idea中Version Control–>log 里每一行记录代表一次push;点开每一行右边显示的是commit详细... -
git_time_extractor:分析Git存储库提交日志,以计算开发人员的工作时间,每周活动并检测软件开发中的死亡...
2021-05-19 15:22:33该工具将通过GIT存储库的提交日志,并基于以下一些假设,为每个开发人员每天的工作时间打印CSV转储: 3小时内的一系列提交是同一开发会话的一部分 一次提交(或会话的第一次提交)被认为代表30分钟的工作时间 开发... -
Git存储库分析器。-Golang开发
2021-05-26 17:03:37Git Repository Analyzer受x0rz的tweets分析器的启发,gitstats是一个简单的工具,目标是对git存储库执行提交活动分析并可视化统计数据,例如:每个用户的活动分布Git Repository Analyzer受x0rz的tweets分析器的... -
git查看日志的常用命令
2019-02-23 19:28:54直接在冒号或者白底黑字的(END)后面输入字符:q,冒号是git log模式下的命令行提示符,白底黑字的(END)提示符代表git log的内容显示完了,但是Gitbash窗口仍然在git log的命令模式下,需要我们输入q字符退出,冒号... -
git-commit-hashtags:在 git commit 消息中使用主题标签
2021-06-02 12:40:29包含提交主题标签的提交可以通过扫描 git 日志并聚合提交主题标签在时间段内、每个作者或其他提交指标的使用情况进行分析。 示例 git 提交消息 Add new class to analyse raw image data #TDD Refactor image ... -
git-analytics
2021-07-03 12:58:28使用它来分析您的 git 日志: 生成项目提交的关键字 生成提交者信息和提交计数 ##设置 要求: Redis 1.安装要求 sudo pip install -r requirements.txt pip install ... -
git push 后产生多余的日志信息
2019-07-05 11:53:31在使用 Git 的进行代码版本控制的时候,往往会发现在 log 中出现 "Merge branch 'master' of ..." 。日志中记录的一般为开发过程中对代码的改动信息,如果出现过多例如上述描述的信息会造成日志的污染。 产生...