Skip to content

Commit 7ddc87d

Browse files
Exclude patch signature from patch file regex & add tests (#13)
* Exclude patch signature from patch file regex * Setup tests * Add tests * Fix --------- Co-authored-by: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
1 parent 3e7dc34 commit 7ddc87d

File tree

8 files changed

+173
-4
lines changed

8 files changed

+173
-4
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ jobs:
1717
- run: bun install
1818
- run: cd web && bun run lint
1919
- run: cd web && bun run check
20+
- run: cd web && bun run test
2021
- run: cd web-extension && bun run lint

bun.lock

Lines changed: 66 additions & 1 deletion
Large diffs are not rendered by default.

web/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"preview": "vite preview",
1212
"prepare": "svelte-kit sync || echo ''",
1313
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
14+
"test": "vitest",
1415
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
1516
"format": "prettier --write .",
1617
"lint": "prettier --check . && eslint ."
@@ -43,7 +44,8 @@
4344
"tailwindcss": "^4.1.8",
4445
"typescript": "^5.8.3",
4546
"typescript-eslint": "^8.33.1",
46-
"vite": "^6.3.5"
47+
"vite": "^6.3.5",
48+
"vitest": "^3.2.4"
4749
},
4850
"dependencies": {
4951
"bits-ui": "^2.4.1",

web/src/lib/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function binaryFileDummyDetails(fromFile: string, toFile: string, status:
101101
};
102102
}
103103

104-
const fileRegex = /diff --git a\/(\S+) b\/(\S+)\r?\n(?:.+\r?\n)*?(?=diff --git|$)/g;
104+
const fileRegex = /diff --git a\/(\S+) b\/(\S+)\r?\n(?:.+\r?\n)*?(?=-- *\r?\n|diff --git|$)/g;
105105

106106
export function splitMultiFilePatch(patchContent: string): FileDetails[] {
107107
const patches: FileDetails[] = [];
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From cfce089822412b142ae1e578111e650d85e64bf7 Mon Sep 17 00:00:00 2001
2+
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
3+
Date: Wed, 18 Jun 2025 18:45:34 +0000
4+
Subject: [PATCH] Import directory diff for patch generation
5+
6+
---
7+
net/minecraft/network/chat/Component.java | 2 +-
8+
net/minecraft/server/network/ServerConnectionListener.java | 2 +-
9+
2 files changed, 2 insertions(+), 2 deletions(-)
10+
11+
diff --git a/net/minecraft/network/chat/Component.java b/net/minecraft/network/chat/Component.java
12+
index c6e4f72..4cebf32 100644
13+
--- a/net/minecraft/network/chat/Component.java
14+
+++ b/net/minecraft/network/chat/Component.java
15+
@@ -39,7 +39,7 @@ import net.minecraft.world.level.ChunkPos;
16+
17+
public interface Component extends Message, FormattedText, Iterable<Component> { // CraftBukkit
18+
19+
- // CraftBukkit start
20+
+ // CraftBukkit start - SUPER complicated change
21+
default java.util.stream.Stream<Component> stream() {
22+
return com.google.common.collect.Streams.concat(java.util.stream.Stream.of(this), this.getSiblings().stream().flatMap(Component::stream));
23+
}
24+
diff --git a/net/minecraft/server/network/ServerConnectionListener.java b/net/minecraft/server/network/ServerConnectionListener.java
25+
index bd07e6a..cd7a5e4 100644
26+
--- a/net/minecraft/server/network/ServerConnectionListener.java
27+
+++ b/net/minecraft/server/network/ServerConnectionListener.java
28+
@@ -108,7 +108,7 @@ public class ServerConnectionListener {
29+
LOGGER.warn("Using HAProxy, please ensure the server port is adequately firewalled.");
30+
}
31+
// Paper end - Warn people with console access that HAProxy is in use.
32+
- // Paper start - Use Velocity cipher
33+
+ // Paper start - Use Velocity cipher huge diff
34+
ServerConnectionListener.LOGGER.info("Paper: Using " + com.velocitypowered.natives.util.Natives.compress.getLoadedVariant() + " compression from Velocity.");
35+
ServerConnectionListener.LOGGER.info("Paper: Using " + com.velocitypowered.natives.util.Natives.cipher.getLoadedVariant() + " cipher from Velocity.");
36+
// Paper end - Use Velocity cipher
37+
--
38+
2.49.0
39+
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
From 3515151127e2cc0ac72f30a7c178a4ed73f31f90 Mon Sep 17 00:00:00 2001
2+
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
3+
Date: Wed, 18 Jun 2025 19:30:57 +0000
4+
Subject: [PATCH] Import directory diff for patch generation
5+
6+
---
7+
net/minecraft/network/chat/Component.java | 2 +-
8+
net/minecraft/server/network/ServerConnectionListener.java | 2 +-
9+
2 files changed, 2 insertions(+), 2 deletions(-)
10+
11+
diff --git a/net/minecraft/network/chat/Component.java b/net/minecraft/network/chat/Component.java
12+
index c6e4f72..4cebf32 100644
13+
--- a/net/minecraft/network/chat/Component.java
14+
+++ b/net/minecraft/network/chat/Component.java
15+
@@ -39,7 +39,7 @@ import net.minecraft.world.level.ChunkPos;
16+
17+
public interface Component extends Message, FormattedText, Iterable<Component> { // CraftBukkit
18+
19+
- // CraftBukkit start
20+
+ // CraftBukkit start - SUPER complicated change
21+
default java.util.stream.Stream<Component> stream() {
22+
return com.google.common.collect.Streams.concat(java.util.stream.Stream.of(this), this.getSiblings().stream().flatMap(Component::stream));
23+
}
24+
diff --git a/net/minecraft/server/network/ServerConnectionListener.java b/net/minecraft/server/network/ServerConnectionListener.java
25+
index bd07e6a..cd7a5e4 100644
26+
--- a/net/minecraft/server/network/ServerConnectionListener.java
27+
+++ b/net/minecraft/server/network/ServerConnectionListener.java
28+
@@ -108,7 +108,7 @@ public class ServerConnectionListener {
29+
LOGGER.warn("Using HAProxy, please ensure the server port is adequately firewalled.");
30+
}
31+
// Paper end - Warn people with console access that HAProxy is in use.
32+
- // Paper start - Use Velocity cipher
33+
+ // Paper start - Use Velocity cipher huge diff
34+
ServerConnectionListener.LOGGER.info("Paper: Using " + com.velocitypowered.natives.util.Natives.compress.getLoadedVariant() + " compression from Velocity.");
35+
ServerConnectionListener.LOGGER.info("Paper: Using " + com.velocitypowered.natives.util.Natives.cipher.getLoadedVariant() + " cipher from Velocity.");
36+
// Paper end - Use Velocity cipher

web/src/test/util.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { expect, test } from "vitest";
2+
import { splitMultiFilePatch } from "$lib/util";
3+
import * as path from "node:path";
4+
import * as fs from "node:fs";
5+
6+
test("Yield 2 patches from a patch file with signature", () => {
7+
const patch = loadPatch("patch-with-signature.patch");
8+
expect(splitMultiFilePatch(patch).length).toBe(2);
9+
});
10+
11+
test("Yield 2 patches from a patch file without signature", () => {
12+
const patch = loadPatch("patch-without-signature.patch");
13+
expect(splitMultiFilePatch(patch).length).toBe(2);
14+
});
15+
16+
export function loadPatch(name: string): string {
17+
const filePath = path.resolve(__dirname, "patches", name);
18+
19+
return fs.readFileSync(filePath, "utf8");
20+
}

web/vite.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import { sveltekit } from "@sveltejs/kit/vite";
2-
import { defineConfig } from "vite";
2+
import { defineConfig } from "vitest/config";
33
import tailwindcss from "@tailwindcss/vite";
44

55
export default defineConfig(() => ({
66
plugins: [tailwindcss(), sveltekit()],
7+
// Tell Vitest to use the `browser` entry points in `package.json` files, even though it's running in Node
8+
resolve: process.env.VITEST
9+
? {
10+
conditions: ["browser"],
11+
}
12+
: undefined,
713
}));

0 commit comments

Comments
 (0)