Skip to content

Instantly share code, notes, and snippets.

@simon0-o
simon0-o / check_commits
Last active April 3, 2024 07:32
Check Commits
#!/bin/bash
# 检查 diff 代码行数是否大于 10000
diff_lines=$(git diff dev --numstat | awk '{ sum += $1 + $2 } END { print sum }')
if [ $diff_lines -gt 10000 ]; then
echo "There are more than 10000 lines changed in current merge request"
exit 1
fi
# 检查 diff commits 数目是否大于 100
@simon0-o
simon0-o / check_branch
Last active April 3, 2024 07:33
check branch name
#!/usr/bin/env bash
basic="(master|develop|main)"
lints="((build|ci|chore|docs|feat|(hot)?fix|perf|refactor|revert|style|test|optimize)/.+)"
other="((release-v[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9.]+(\+[a-z0-9.]+)?)?)|revert-[a-z0-9]+)"
pattern="^(${basic}|${lints}|${other})$"
current=$(git status | head -n1 | sed 's/On branch //')
name=${1:-$current}
if [[ ! $name =~ $pattern ]]; then