Keep copied source packages out of parent Git repositories

This commit is contained in:
gitea committed 2026-10-12 12:27:46 +08:00
1 parent 2654e1b870
commit fa304ca4dc
4 files changed
+33 -4

No files matched your search

+7 -1
View File
@@ -1,6 +1,7 @@
import { spawnSync } from "node:child_process";
import { dirname, resolve } from "node:path";
import { dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { existsSync } from "node:fs";
import packageJson from "../package.json" with { type: "json" };
export interface GitBuildInfo {
@@ -124,6 +125,11 @@ export function resolveVersionInfo(options?: {
// 3. Dynamic resolution from git repository in dev mode
try {
// A copied npm package has no checkout. Git would otherwise walk up into
// the consuming application's repository and report its version as ours.
if (options?.cwd === undefined && !existsSync(join(cwd, ".git"))) {
return { name: "seal-use", version: `${packageJson.version}-dev.0+local`, channel: "dev", isRelease: false };
}
const res = spawnSync("git", ["describe", "--tags", "--long", "--dirty", "--always"], {
cwd,
encoding: "utf8",