#!/usr/bin/env bash## An example hook script to check the commit log message.# Called by "git commit" with one argument, the name of the file# that has the commit message. The hook should exit with non-zero# status after issuing an appropriate message if it wants to stop the# commit. The hook is allowed to edit the commit message file.## To enable this hook, rename this file to "commit-msg".# Uncomment the below to add a Signed-off-by line to the message.# Doing this in a hook is a bad idea in general, but the prepare-commit-msg# hook is more suited to it.## SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: 1円/p')# grep -qs "^$SOB" "1ドル" || echo "$SOB" >> "1ドル"# This example catches duplicate Signed-off-by lines.test "" = "$(grep '^Signed-off-by: ' "1ドル" |sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {echo >&2 Duplicate Signed-off-by lines.exit 1}COMMIT_MSG_FILE=1ドルmsg="$(grep -v '^#' "$COMMIT_MSG_FILE")"echo -e "0円33[33m The commit msg: 0円33[0m $msg"#if the msg is merge then skip itmergePattern='^Merge 'if [[ "$msg" =~ "$mergePattern" ]];thenecho -e "0円33[32m skip the merge, commit success! 0円33[0m"exit 0fi# check the first line of the commit msgmaxlen=200first_line=$(echo "$msg" | head -n 1)length=${#first_line}msg_re="^(feat|fix|docs|style|refactor|test|chore)(\(.+\))?: .{1,200}"if [[ ! $first_line =~ $msg_re ]];thenecho -e "0円33[31m Error: the commit message is irregular 0円33[0m"echo -e "0円33[31m Error: type must be one of [feat|fix|docs|style|refactor|test|chore]0円33[0m"echo -e "0円33[31m eg: feat(user): add the user login 0円33[0m"echo -e "0円33[31m See: https://confluence.shell.com.cn:9443/pages/viewpage.action?pageId=137398003 for details0円33[0m"exit 1elseif [ $length -gt $maxlen ];thenecho -e "0円33[31m Error: the first line of the commit message exceeds the max length of 200 characters 0円33[0m"exit 1fifiexit 0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。