File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 : 生成补丁文件
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 个补丁文件"
You can’t perform that action at this time.
0 commit comments