add-git-tag

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Add Git Tag Workflow

添加Git标签工作流

Use this workflow whenever the user wants to mark a milestone in the current Git repository with a tag. The agent must ask the user for all required information before executing any commands.
当用户想要用标签标记当前Git仓库中的里程碑时,可使用此工作流。在执行任何命令之前,Agent必须向用户询问所有必要信息

Step 1 — Gather Information (Ask the user)

步骤1 — 收集信息(询问用户)

Ask the user the following three questions in a single message (do NOT run any commands yet):
  1. Tag version: What should the tag name be? (e.g.
    v0.1.3
    )
  2. Achievements: What was accomplished in this phase? (provide a short bullet-point list of features/fixes completed)
  3. Next plans: What is planned for the next phase? (provide a short bullet-point list of upcoming goals)
Wait for the user's answers before proceeding.
在一条消息中向用户询问以下三个问题(暂不运行任何命令):
  1. 标签版本:标签名称是什么?(例如
    v0.1.3
  2. 已完成成果:此阶段完成了哪些内容?(提供已完成功能/修复的简短项目符号列表)
  3. 下一阶段计划:下一阶段的计划是什么?(提供即将实现目标的简短项目符号列表)
等待用户回复后再继续。

Step 2 — Confirm the tag message (Show a preview)

步骤2 — 确认标签消息(显示预览)

After collecting the user's answers, compose and display the full annotated tag message for the user to review. The format should be:
Tag: <version>
Date: <current date, YYYY-MM-DD>
收集用户的回答后,编写并展示完整的带注释标签消息供用户审核。格式如下:
Tag: <version>
Date: <当前日期,YYYY-MM-DD>

✅ This Phase — What Was Achieved

✅ 本阶段 — 已完成成果

  • <bullet 1>
  • <bullet 2> ...
  • <项目符号1>
  • <项目符号2> ...

🚀 Next Phase — What's Planned

🚀 下一阶段 — 计划内容

  • <bullet 1>
  • <bullet 2> ...

Ask the user: **"Does this look good? Should I go ahead and create the tag?"**

Wait for confirmation before proceeding.
  • <项目符号1>
  • <项目符号2> ...

询问用户:**“这个内容看起来没问题吧?是否要继续创建标签?”**

等待用户确认后再继续。

Step 3 — Verify the repository state

步骤3 — 验证仓库状态

// turbo Detect the current Git project root and check status:
bash
REPO=$(git rev-parse --show-toplevel 2>/dev/null) && \
git -C "$REPO" log --oneline -5 && \
git -C "$REPO" status --short && \
git -C "$REPO" tag --sort=-version:refname | head -5
This gives the last 5 commits, any uncommitted changes, and the 5 most recent existing tags.
// turbo 检测当前Git项目根目录并检查状态:
bash
REPO=$(git rev-parse --show-toplevel 2>/dev/null) && \
git -C "$REPO" log --oneline -5 && \
git -C "$REPO" status --short && \
git -C "$REPO" tag --sort=-version:refname | head -5
此命令会显示最近5次提交记录、所有未提交的更改以及最近的5个现有标签。

Step 4 — Create the annotated tag

步骤4 — 创建带注释的标签

// turbo Detect the repo root and create the tag:
bash
REPO=$(git rev-parse --show-toplevel)
git -C "$REPO" tag -a "<version>" -m "<full_tag_message>"
Where:
  • <version>
    is the tag name from the user (e.g.
    v0.1.3
    )
  • <full_tag_message>
    is the full formatted message from Step 2
// turbo 检测仓库根目录并创建标签:
bash
REPO=$(git rev-parse --show-toplevel)
git -C "$REPO" tag -a "<version>" -m "<full_tag_message>"
其中:
  • <version>
    是用户提供的标签名称(例如
    v0.1.3
  • <full_tag_message>
    是步骤2中生成的完整格式化消息

Step 5 — Push the tag to remote (ask first)

步骤5 — 将标签推送到远程仓库(先询问用户)

Ask the user: "Would you like to push the tag
<version>
to the remote repository (origin)?"
If yes: // turbo
bash
REPO=$(git rev-parse --show-toplevel)
git -C "$REPO" push origin "<version>"
If no, inform the user that the tag was created locally and can be pushed later with:
bash
git push origin <version>
询问用户:“是否要将标签
<version>
推送到远程仓库(origin)?”
如果用户同意: // turbo
bash
REPO=$(git rev-parse --show-toplevel)
git -C "$REPO" push origin "<version>"
如果用户不同意,告知用户标签已在本地创建,后续可使用以下命令推送:
bash
git push origin <version>

Step 6 — Confirm success

步骤6 — 确认操作成功

bash
REPO=$(git rev-parse --show-toplevel)
git -C "$REPO" tag -n1 <version>
Report the outcome to the user:
  • Show the tag that was created
  • Confirm whether it was pushed to remote
  • Remind the user they can view all tags with
    git tag -n1 --sort=-version:refname
bash
REPO=$(git rev-parse --show-toplevel)
git -C "$REPO" tag -n1 <version>
向用户报告结果:
  • 显示已创建的标签
  • 确认是否已推送到远程仓库
  • 提醒用户可使用
    git tag -n1 --sort=-version:refname
    查看所有标签