fix: 简化远程 .version 获取方式,去除 OneDev 不支持的 sparse filter

This commit is contained in:
2026-05-24 22:40:16 +08:00
parent f7060b056d
commit 06def78f6b
+4 -10
View File
@@ -129,6 +129,7 @@ export function getRemoteVersionFile(): VersionFile | null {
/**
* 通过浅克隆获取远程 .version 文件(备选方案)
* OneDev 不支持 git archive --remote,改用完整浅克隆
*/
function getRemoteVersionByClone(): VersionFile | null {
const tmpDir = path.join(
@@ -137,18 +138,11 @@ function getRemoteVersionByClone(): VersionFile | null {
);
try {
const url = getAuthenticatedRemoteUrl();
execSync(
`git clone --depth 1 --filter=blob:none --sparse "${url}" "${tmpDir}" 2>nul`,
{
execSync(`git clone --depth 1 "${url}" "${tmpDir}"`, {
encoding: "utf-8",
timeout: 30000,
windowsHide: true,
}
);
execSync(`cd "${tmpDir}" && git sparse-checkout set .version 2>nul`, {
encoding: "utf-8",
timeout: 10000,
timeout: 60000,
windowsHide: true,
stdio: ["ignore", "pipe", "pipe"],
});
const versionPath = path.join(tmpDir, ".version");
if (fs.existsSync(versionPath)) {