Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用于发布Git挂钩的Bash脚本_Bash_Github_Git Bash - Fatal编程技术网

用于发布Git挂钩的Bash脚本

用于发布Git挂钩的Bash脚本,bash,github,git-bash,Bash,Github,Git Bash,我的项目使用一个gitHub存储库,Mac和Windows用户都在其中提交代码。 我已经设置了一个客户端钩子,通过修改hooks文件夹中的提交消息钩子,将JIRA Id包含在提交消息中。 但是,由于客户端钩子无法发布,编写脚本并将其包含在repo中将有助于修改文件。是否有可能编写一个可以在windows和Mac上运行的通用脚本。 脚本需要执行以下操作 将commit-msg.sample重命名为commit-msg 将文件内容替换为以下代码 代码如下 commit_regex='(ISSU

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

  • 将commit-msg.sample重命名为commit-msg
  • 将文件内容替换为以下代码
代码如下

 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" "$1"; then
echo "$error_msg" >&2
exit 1
fi
是否可以编写一个在windows和Mac上都能工作的通用脚本

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


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

使用可移植的解决方案,例如Perl或Java?