[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot]
2026-02-17 06:04:26 +00:00
committed by GitHub
parent 0fc043d0ad
commit 752f90c330
10 changed files with 21293 additions and 22887 deletions

View File

@@ -1,4 +1,3 @@
import { existsSync } from "node:fs";
import path from "node:path";
import type { ApplicationNested } from "@dokploy/server";
@@ -80,9 +79,8 @@ vi.mock("@dokploy/server/services/rollbacks", () => ({
}));
vi.mock("@dokploy/server/services/patch", async (importOriginal) => {
const actual = await importOriginal<
typeof import("@dokploy/server/services/patch")
>();
const actual =
await importOriginal<typeof import("@dokploy/server/services/patch")>();
return {
...actual,
findPatchesByApplicationId: vi.fn().mockResolvedValue([]),
@@ -507,7 +505,8 @@ describe(
// 1. Setup local temporary git repo
const tempRepo = await mkdtemp(join(tmpdir(), "real-patch-repo-"));
// Helper for local git commands
const execLocal = async (cmd: string) => execAsync(cmd, { cwd: tempRepo });
const execLocal = async (cmd: string) =>
execAsync(cmd, { cwd: tempRepo });
await execLocal("git init");
await execLocal("git config user.email 'test@dokploy.com'");
@@ -518,7 +517,7 @@ describe(
await writeFile(join(tempRepo, "app.py"), "print('Original App')\n");
await writeFile(
join(tempRepo, "Dockerfile"),
"FROM python:3.9-slim\nCOPY app.py .\nCMD [\"python\", \"app.py\"]\n",
'FROM python:3.9-slim\nCOPY app.py .\nCMD ["python", "app.py"]\n',
);
await execLocal("git add .");

View File

@@ -1,4 +1,3 @@
import { generatePatch } from "@dokploy/server/services/patch";
import { describe, expect, it, afterEach } from "vitest";
import { mkdtemp, rm, writeFile, readFile } from "node:fs/promises";
@@ -23,16 +22,18 @@ describe("Patch System Integration", () => {
tempDir = await mkdtemp(join(tmpdir(), "dokploy-patch-test-"));
const fileName = "test.txt";
const filePath = join(tempDir, fileName);
await execAsyncLocal("git init", { cwd: tempDir });
await execAsyncLocal("git config user.email 'test@test.com'", { cwd: tempDir });
await execAsyncLocal("git config user.email 'test@test.com'", {
cwd: tempDir,
});
await execAsyncLocal("git config user.name 'Test'", { cwd: tempDir });
// Original content
await writeFile(filePath, "line1\nline2\n");
await execAsyncLocal(`git add ${fileName}`, { cwd: tempDir });
await execAsyncLocal("git commit -m 'init'", { cwd: tempDir });
// Generate patch (modify content)
const newContent = "line1\nline2\nline3\n";
const patchContent = await generatePatch({
@@ -41,7 +42,7 @@ describe("Patch System Integration", () => {
newContent,
serverId: null,
});
// Verify patch format
expect(patchContent.endsWith("\n")).toBe(true);
@@ -49,20 +50,22 @@ describe("Patch System Integration", () => {
await execAsyncLocal("git checkout .", { cwd: tempDir });
const savedContent = await readFile(filePath, "utf-8");
expect(savedContent).toBe("line1\nline2\n");
// Apply patch verification
// We simulate what Deployment Service does: write patch to file and run git apply
const patchFile = join(tempDir, "changes.patch");
await writeFile(patchFile, patchContent);
try {
await execAsyncLocal(`git apply --whitespace=fix ${patchFile}`, { cwd: tempDir });
await execAsyncLocal(`git apply --whitespace=fix ${patchFile}`, {
cwd: tempDir,
});
} catch (e: any) {
console.error("Git apply failed:", e.message);
console.log("Patch content:", JSON.stringify(patchContent));
throw e;
}
const appliedContent = await readFile(filePath, "utf-8");
expect(appliedContent).toBe(newContent);
});
@@ -72,17 +75,19 @@ describe("Patch System Integration", () => {
tempDir = await mkdtemp(join(tmpdir(), "dokploy-patch-test-noline-"));
const fileName = "noline.txt";
const filePath = join(tempDir, fileName);
await execAsyncLocal("git init", { cwd: tempDir });
await execAsyncLocal("git config user.email 'test@test.com'", { cwd: tempDir });
await execAsyncLocal("git config user.email 'test@test.com'", {
cwd: tempDir,
});
await execAsyncLocal("git config user.name 'Test'", { cwd: tempDir });
// Original content WITHOUT newline
await writeFile(filePath, "line1");
await execAsyncLocal(`git add ${fileName}`, { cwd: tempDir });
await execAsyncLocal("git commit -m 'init'", { cwd: tempDir });
// Generate patch
// Generate patch
const newContent = "line1\nline2";
const patchContent = await generatePatch({
codePath: tempDir,
@@ -93,13 +98,15 @@ describe("Patch System Integration", () => {
// Verify patch format
expect(patchContent.endsWith("\n")).toBe(true);
// Apply patch
const patchFile = join(tempDir, "changes.patch");
await writeFile(patchFile, patchContent);
await execAsyncLocal(`git apply --whitespace=fix ${patchFile}`, { cwd: tempDir });
await execAsyncLocal(`git apply --whitespace=fix ${patchFile}`, {
cwd: tempDir,
});
const appliedContent = await readFile(filePath, "utf-8");
expect(appliedContent).toBe(newContent);
});