Bash 发布脚本 Git 挂钩

Bash Script for Publishing Git hooks

我的项目使用单个 gitHub 存储库,Mac 和 Windows 用户都在其中提交代码。 我已经设置了一个客户端挂钩,以便通过修改 hooks 文件夹中的提交消息挂钩将 JIRA Id 包含在提交消息中。 但是,由于无法发布客户端挂钩,因此编写脚本并将其包含在存储库中将有助于修改文件。是否可以编写一个适用于 windows 和 Mac 的通用脚本。 该脚本需要执行以下操作。

下面的代码

 commit_regex='(ISSUE-[0-9]+|merge)'
 error_msg="Aborting commit. Your commit message is missing either a JIRA      Issue ('ISSUE-1111') or 'Merge'"

if ! grep -iqE "$commit_regex" ""; then
echo "$error_msg" >&2
exit 1
fi

Is it possible to write a common script that would work on both windows and Mac

您只需编写一个 bash 脚本:它将由 Git bash 解释,它甚至存在于 Windows.

任何以#!/bin/bash 开头的可执行脚本都可以。