test(coding-agent): stabilize git update branch setup
This commit is contained in:
@@ -27,6 +27,12 @@ function git(args: string[], cwd: string): string {
|
|||||||
return result.stdout.trim();
|
return result.stdout.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initGitRepo(repoDir: string): void {
|
||||||
|
git(["init", "--initial-branch=main"], repoDir);
|
||||||
|
git(["config", "--local", "user.email", "test@test.com"], repoDir);
|
||||||
|
git(["config", "--local", "user.name", "Test"], repoDir);
|
||||||
|
}
|
||||||
|
|
||||||
// Helper to create a commit with a file
|
// Helper to create a commit with a file
|
||||||
function createCommit(repoDir: string, filename: string, content: string, message: string): string {
|
function createCommit(repoDir: string, filename: string, content: string, message: string): string {
|
||||||
writeFileSync(join(repoDir, filename), content);
|
writeFileSync(join(repoDir, filename), content);
|
||||||
@@ -91,9 +97,7 @@ describe("DefaultPackageManager git update", () => {
|
|||||||
function setupRemoteAndInstall(sourceOverride?: string): void {
|
function setupRemoteAndInstall(sourceOverride?: string): void {
|
||||||
// Create "remote" repository
|
// Create "remote" repository
|
||||||
mkdirSync(remoteDir, { recursive: true });
|
mkdirSync(remoteDir, { recursive: true });
|
||||||
git(["init"], remoteDir);
|
initGitRepo(remoteDir);
|
||||||
git(["config", "--local", "user.email", "test@test.com"], remoteDir);
|
|
||||||
git(["config", "--local", "user.name", "Test"], remoteDir);
|
|
||||||
createCommit(remoteDir, "extension.ts", "// v1", "Initial commit");
|
createCommit(remoteDir, "extension.ts", "// v1", "Initial commit");
|
||||||
|
|
||||||
// Clone to installed directory (simulating what install() does)
|
// Clone to installed directory (simulating what install() does)
|
||||||
@@ -109,9 +113,7 @@ describe("DefaultPackageManager git update", () => {
|
|||||||
describe("normal updates (no force-push)", () => {
|
describe("normal updates (no force-push)", () => {
|
||||||
it("should skip reset, clean, and install when already up to date", async () => {
|
it("should skip reset, clean, and install when already up to date", async () => {
|
||||||
mkdirSync(remoteDir, { recursive: true });
|
mkdirSync(remoteDir, { recursive: true });
|
||||||
git(["init"], remoteDir);
|
initGitRepo(remoteDir);
|
||||||
git(["config", "--local", "user.email", "test@test.com"], remoteDir);
|
|
||||||
git(["config", "--local", "user.name", "Test"], remoteDir);
|
|
||||||
writeFileSync(join(remoteDir, "package.json"), JSON.stringify({ name: "test-extension", version: "1.0.0" }));
|
writeFileSync(join(remoteDir, "package.json"), JSON.stringify({ name: "test-extension", version: "1.0.0" }));
|
||||||
createCommit(remoteDir, "extension.ts", "// v1", "Initial commit");
|
createCommit(remoteDir, "extension.ts", "// v1", "Initial commit");
|
||||||
|
|
||||||
@@ -283,9 +285,7 @@ describe("DefaultPackageManager git update", () => {
|
|||||||
it("should not update pinned git sources (with @ref)", async () => {
|
it("should not update pinned git sources (with @ref)", async () => {
|
||||||
// Create remote repo first to get the initial commit
|
// Create remote repo first to get the initial commit
|
||||||
mkdirSync(remoteDir, { recursive: true });
|
mkdirSync(remoteDir, { recursive: true });
|
||||||
git(["init"], remoteDir);
|
initGitRepo(remoteDir);
|
||||||
git(["config", "--local", "user.email", "test@test.com"], remoteDir);
|
|
||||||
git(["config", "--local", "user.name", "Test"], remoteDir);
|
|
||||||
const initialCommit = createCommit(remoteDir, "extension.ts", "// v1", "Initial commit");
|
const initialCommit = createCommit(remoteDir, "extension.ts", "// v1", "Initial commit");
|
||||||
|
|
||||||
// Install with pinned ref from the start - full clone to ensure commit is available
|
// Install with pinned ref from the start - full clone to ensure commit is available
|
||||||
|
|||||||
Reference in New Issue
Block a user