是否可以自动分割一个提交Github比较视图? [英] Is it possible to automatically split a commit for Github compare view?

查看:249
本文介绍了是否可以自动分割一个提交Github比较视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们公司,代码审查是在Github比较视图中添加评论。当然你可以使用difftool或有些。但我想知道是否有一种方法,当它超过 Github的限制

At our company code reviews are done in Github compare view by adding comments. Of course you can use difftool or someting. But I'd like to know if there is a way to automatically warn / split a commit when it exceeds the Github limits?

推荐答案

您可以使用提交前钩子以防止大提交。例如。检查diff的行数,保存如下 [REPO PATH] /。git / hooks / pre-commit 并使其可执行(例如 chmod + x 在linux上):

You can use a pre-commit hook to prevent large commits. E.g. to check the diff's number of lines, save the following as [REPO PATH]/.git/hooks/pre-commit and make it executable (e.g. chmod +x on linux):

#!/usr/bin/env bash
[[ $(git diff --cached | wc -l) > 300 ]] && { echo "Commit too long"; exit 1; }

或检查文件大小:

tmp=$(mktemp /tmp/git_XXXXX)
git diff --cached > "$tmp"
[[ $(ls -l "$tmp" | awk '{print $5}') > 10000 ]] && { echo "Commit too large"; exit 1; }  

这篇关于是否可以自动分割一个提交Github比较视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆