Files
gerrit/快速修复Change-Id.sh
2025-12-22 17:12:39 +08:00

70 lines
1.6 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 快速修复 Gerrit Change-Id 问题的脚本
echo "=========================================="
echo "安装 Gerrit commit-msg Hook"
echo "=========================================="
# 检查是否在 Git 仓库中
if [ ! -d .git ]; then
echo "❌ 错误:当前目录不是 Git 仓库"
echo " 请先进入项目目录cd /d/zhini_im_android"
exit 1
fi
echo ""
echo "步骤 1: 创建 hooks 目录..."
mkdir -p .git/hooks
echo ""
echo "步骤 2: 下载 commit-msg hook..."
# 使用 HTTP 方式下载(最简单可靠)
curl -o .git/hooks/commit-msg http://101.43.95.130:8080/tools/hooks/commit-msg
if [ $? -eq 0 ]; then
echo "✅ Hook 下载成功"
else
echo "❌ Hook 下载失败,请检查网络连接"
exit 1
fi
echo ""
echo "步骤 3: 设置执行权限..."
chmod +x .git/hooks/commit-msg
if [ -x .git/hooks/commit-msg ]; then
echo "✅ Hook 权限设置成功"
else
echo "❌ Hook 权限设置失败"
exit 1
fi
echo ""
echo "步骤 4: 验证 hook 已安装..."
if [ -f .git/hooks/commit-msg ]; then
echo "✅ commit-msg hook 已安装"
echo " 文件位置: $(pwd)/.git/hooks/commit-msg"
else
echo "❌ Hook 文件不存在"
exit 1
fi
echo ""
echo "=========================================="
echo "Hook 安装完成!"
echo "=========================================="
echo ""
echo "下一步操作:"
echo ""
echo "1. 修改最后一次提交以添加 Change-Id"
echo " git commit --amend --no-edit"
echo ""
echo "2. 查看提交信息确认 Change-Id 已添加:"
echo " git log -1"
echo ""
echo "3. 重新推送代码:"
echo " git push origin HEAD:refs/for/master"
echo ""