如何将 Change-id 附加到自定义提交消息挂钩中的提交消息?
How to append Change-id to commit message inside custom commit-msg hook?
我已经准备好自己的提交消息模板和提交消息挂钩用于验证目的。这个钩子是一个简单的 Python 脚本。它有效,但我想在我的提交消息底部也有 Change-id 。
我从 gerrit 看到我可以下载写在 Bash 中的 commit-msg 钩子,这个钩子提供了 Change-id 生成的解决方案:
https://gerrit-review.googlesource.com/Documentation/user-changeid.html。
但现在我有 2 个不同的 commit-msg 挂钩。那么我应该重写自己的 msg-hook 并将其附加到那个官方 msg-hook 模板,还是我应该编写自己的 Change-id 生成器实现?
通过将 </code> 输入参数替换为您的脚本输出 </p>,修改原始 commit-msg 钩子开头的 <code>MSG
变量定义
#!/bin/sh
# From Gerrit Code Review 2.14.20-179-g6c46f4efba
#
# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
#
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
unset GREP_OPTIONS
CHANGE_ID_AFTER="Bug|Depends-On|Issue|Test|Feature|Fixes|Fixed"
MSG=`python /path/to/myscript.py`
# Check for, and add if missing, a unique Change-Id
#
add_ChangeId() {
clean_message=`sed -e '
我已经准备好自己的提交消息模板和提交消息挂钩用于验证目的。这个钩子是一个简单的 Python 脚本。它有效,但我想在我的提交消息底部也有 Change-id 。 我从 gerrit 看到我可以下载写在 Bash 中的 commit-msg 钩子,这个钩子提供了 Change-id 生成的解决方案: https://gerrit-review.googlesource.com/Documentation/user-changeid.html。 但现在我有 2 个不同的 commit-msg 挂钩。那么我应该重写自己的 msg-hook 并将其附加到那个官方 msg-hook 模板,还是我应该编写自己的 Change-id 生成器实现?
通过将 </code> 输入参数替换为您的脚本输出 </p>,修改原始 commit-msg 钩子开头的 <code>MSG
变量定义
#!/bin/sh
# From Gerrit Code Review 2.14.20-179-g6c46f4efba
#
# Part of Gerrit Code Review (https://www.gerritcodereview.com/)
#
# Copyright (C) 2009 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
unset GREP_OPTIONS
CHANGE_ID_AFTER="Bug|Depends-On|Issue|Test|Feature|Fixes|Fixed"
MSG=`python /path/to/myscript.py`
# Check for, and add if missing, a unique Change-Id
#
add_ChangeId() {
clean_message=`sed -e '