Skip to content

Commit 47ddc9d

Browse files
authored
Update main.yml
1 parent 24ea563 commit 47ddc9d

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

.github/workflows/main.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ jobs:
4040
- name: 克隆源仓库
4141
run: |
4242
cd source_repo
43+
# 使用轻量克隆
4344
if [ -n "${{ github.event.inputs.branch }}" ]; then
4445
echo "正在克隆 ${{ github.event.inputs.repo_url }} 的分支: ${{ github.event.inputs.branch }}"
45-
git clone --single-branch --branch "${{ github.event.inputs.branch }}" "${{ github.event.inputs.repo_url }}" .
46+
git clone --depth 100 --single-branch --branch "${{ github.event.inputs.branch }}" "${{ github.event.inputs.repo_url }}" .
4647
else
4748
echo "正在克隆 ${{ github.event.inputs.repo_url }} 的默认分支"
48-
git clone --single-branch "${{ github.event.inputs.repo_url }}" .
49+
git clone --depth 100 --single-branch "${{ github.event.inputs.repo_url }}" .
4950
fi
5051
5152
- name: 生成补丁文件
@@ -82,8 +83,11 @@ jobs:
8283
echo "已生成单个补丁文件: combined.patch"
8384
else
8485
echo "正在生成多个补丁文件..."
85-
# 获取完整历史以生成多个补丁
86-
git fetch --unshallow
86+
# 仅在需要时获取更多历史
87+
if ! git merge-base --is-ancestor "$START_HASH" "$END_HASH" 2>/dev/null; then
88+
echo "提交范围不在当前克隆深度内,获取更多历史..."
89+
git fetch --unshallow || git fetch --depth=1000
90+
fi
8791
git format-patch "$START_HASH..$END_HASH" -o "$OUTPUT_DIR" --quiet
8892
PATCH_COUNT=$(ls -1 "$OUTPUT_DIR"/*.patch 2>/dev/null | wc -l)
8993
echo "已生成 $PATCH_COUNT 个补丁文件"

0 commit comments

Comments
 (0)