From 89c7782768d14a79316c3cb857a7b90e1efc46b5 Mon Sep 17 00:00:00 2001 From: dafe Date: Tue, 10 Nov 2026 12:36:09 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=96=B0=E5=A2=9E=20feature=20?= =?UTF-8?q?=E5=88=86=E6=94=AF=E5=90=88=E5=B9=B6=E5=90=8E=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E6=B8=85=E7=90=86=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/finish-feature.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 tools/finish-feature.sh diff --git a/tools/finish-feature.sh b/tools/finish-feature.sh new file mode 100755 index 0000000..ad44977 --- /dev/null +++ b/tools/finish-feature.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash +# 在 feature 分支上执行:合并到 main、推送、删除本地和远端分支 +# 用法:bash tools/finish-feature.sh +set -euo pipefail + +BRANCH=$(git branch --show-current) +if [[ ! "$BRANCH" =~ ^feature/ ]]; then + echo "❌ 当前分支不是 feature/*:${BRANCH}" + exit 1 +fi + +if ! git diff --quiet || ! git diff --cached --quiet; then + echo "❌ 工作区有未提交改动,先提交或暂存" + exit 1 +fi + +echo "== 合并 ${BRANCH} → main" +git checkout main +git pull --ff-only origin main +git merge --no-ff "$BRANCH" -m "Merge branch '${BRANCH}'" +git push origin main + +echo "== 清理分支 ${BRANCH}" +git branch -d "$BRANCH" +if git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then + git push origin --delete "$BRANCH" +fi + +echo "✅ 已合并并清理 ${BRANCH}"