Compare commits

...

3 Commits

Author SHA1 Message Date
e3166b639e 操作步骤调整 2026-05-17 12:13:50 +08:00
3d26bbe090 提交内容整理 2026-05-17 12:08:22 +08:00
cd375cefc5 直接取远程分支 origin/xxx 最新全量 Commit,不限制子目录
​
2. 优化标签匹配:只要标签前缀是  模块名-  就匹配
​
3. 保留你原有全部脚本结构,只改  get_module_latest_tag  函数
2026-05-17 11:35:41 +08:00

View File

@@ -12,18 +12,22 @@ get_module_latest_tag() {
# 先同步远程分支元数据
git fetch origin "$module_dir" 2>/dev/null
# 获取该模块目录最新一次提交CommitHash
# 修复取整个远程分支最新Commit不限制子目录
local latest_commit
latest_commit=$(git log -1 --pretty=format:%H "$remote_branch" -- "$module_dir"/ 2>/dev/null)
latest_commit=$(git log -1 --pretty=format:%H "$remote_branch" 2>/dev/null)
echo " 调试:模块[$module_dir] 远程分支最新Commit = $latest_commit"
# 无commit直接返回空
[ -z "$latest_commit" ] && return
if [ -z "$latest_commit" ]; then
echo " 调试未获取到有效Commit跳过"
return
fi
# 匹配远程同commit、模块前缀的标签过滤废弃^{}引用
git ls-remote --tags origin "${module_dir}*" 2>/dev/null \
# 精准匹配:模块名- 开头标签 + 严格比对commit哈希
git ls-remote --tags origin "${module_dir}-*" 2>/dev/null \
| grep -v '\^{}' \
| grep "$latest_commit" \
| awk '{print $2}' \
| awk -v target_commit="$latest_commit" '$1 == target_commit {print $2}' \
| sed "s/refs\/tags\///"
}
@@ -191,6 +195,7 @@ echo -e "#@@@ 开始合并应用型模块源码 @@@#"
for item in "${MERGE_APP_PROJECT_LIST[@]}"; do
item_lower=$(echo "$item" | tr 'A-Z' 'a-z')
MOD_TAG=$(get_module_latest_tag "$item_lower")
# 无标签直接跳过所有操作不checkout、不add、不commit
if [ -z "$MOD_TAG" ]; then
echo "跳过 $item_lower :最新提交未打标签"
continue
@@ -198,8 +203,7 @@ for item in "${MERGE_APP_PROJECT_LIST[@]}"; do
echo "合并 $item_lower 远程分支origin/$item_lower,标签:$MOD_TAG"
git checkout origin/$item_lower $item_lower
git add .
# 提交备注带上标签名
git commit -m "合并 $item 项目,关联标签:$MOD_TAG"
git commit -m "合并 $item 项目,$MOD_TAG"
done
## 合并 LIB 项目
@@ -213,6 +217,7 @@ echo -e "#@@@ 开始合并类库型模块源码 @@@#"
for item in "${MERGE_LIB_PROJECT_LIST[@]}"; do
item_lower=$(echo "$item" | tr 'A-Z' 'a-z')
MOD_TAG=$(get_module_latest_tag "$item_lower")
# 无标签直接跳过所有操作
if [ -z "$MOD_TAG" ]; then
echo "跳过 $item_lower :最新提交未打标签"
continue
@@ -220,8 +225,7 @@ for item in "${MERGE_LIB_PROJECT_LIST[@]}"; do
echo "合并 $item_lower 远程分支origin/$item_lower,标签:$MOD_TAG"
git checkout origin/$item_lower $item_lower lib$item_lower
git add .
# 提交备注带上标签名
git commit -m "合并 $item 项目,关联标签:$MOD_TAG"
git commit -m "合并 $item 项目,$MOD_TAG"
done
echo '正在推送 Projects_Keeper 项目'