nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: preactjs/preact-devtools
Pull request #166 (2020-04-21 20:33:06)

Fix possible exception in hooks parsing code


Patch:
diff --git a/src/view/components/sidebar/inspect/parseProps.ts b/src/view/components/sidebar/inspect/parseProps.ts
index cc10fe0..cc6f600 100644
--- a/src/view/components/sidebar/inspect/parseProps.ts
+++ b/src/view/components/sidebar/inspect/parseProps.ts
@@ -32,12 +32,22 @@ export function parseProps(
 	out: Map<string, PropData>,
 ): Map<string, PropData> {
 	const depth = (path.match(/\./g) || []).length;
+	const name = path.slice(path.lastIndexOf(".") + 1);
+
 	if (depth >= limit) {
+		out.set(path, {
+			depth,
+			name,
+			id: path,
+			type: "string",
+			editable: false,
+			value: "…",
+			children: [],
+			meta: null,
+		});
 		return out;
 	}
 
-	const name = path.slice(path.lastIndexOf(".") + 1);
-
 	if (Array.isArray(data)) {
 		const children: string[] = [];
 		out.set(path, {


Test patch:
diff --git a/src/view/components/sidebar/inspect/parseProps.test.ts b/src/view/components/sidebar/inspect/parseProps.test.ts
index 802fa72..670af94 100644
--- a/src/view/components/sidebar/inspect/parseProps.test.ts
+++ b/src/view/components/sidebar/inspect/parseProps.test.ts
@@ -252,7 +252,7 @@ describe("parseProps", () => {
 
 	it("should limit depth", () => {
 		const tree = new Map();
-		parseProps({ foo: { bar: "abc" } }, "foo", 2, tree);
+		parseProps({ foo: { bar: { boof: "abc" } } }, "foo", 2, tree);
 		expect(serialize(tree)).to.deep.equal([
 			{
 				editable: false,
@@ -262,7 +262,7 @@ describe("parseProps", () => {
 				type: "object",
 				value: {
 					foo: {
-						bar: "abc",
+						bar: { boof: "abc" },
 					},
 				},
 				children: ["foo.foo"],
@@ -275,11 +275,21 @@ describe("parseProps", () => {
 				name: "foo",
 				type: "object",
 				value: {
-					bar: "abc",
+					bar: { boof: "abc" },
 				},
 				children: ["foo.foo.bar"],
 				meta: null,
 			},
+			{
+				editable: false,
+				depth: 2,
+				id: "foo.foo.bar",
+				name: "bar",
+				type: "string",
+				value: "…",
+				children: [],
+				meta: null,
+			},
 		]);
 	});
Repository: preactjs/preact-devtools
Pull request #419 (2022-08-27 15:42:46)

Fix inspect data not cleared on disconnect


Patch:
diff --git a/src/view/store/index.ts b/src/view/store/index.ts
index d05c719..98a0f0b 100644
--- a/src/view/store/index.ts
+++ b/src/view/store/index.ts
@@ -136,6 +136,7 @@ export function createStore(): Store {
 			selection.selected.value = -1;
 			collapser.collapsed.value = new Set();
 			stats.value = null;
+			inspectData.value = null;
 		},
 		subscribe(fn) {
 			const idx = listeners.push(fn);


Test patch:
diff --git a/src/adapter/store.test.ts b/src/adapter/store.test.ts
index 51f5328..4a6e349 100644
--- a/src/adapter/store.test.ts
+++ b/src/adapter/store.test.ts
@@ -71,4 +71,22 @@ describe("Store", () => {
 		expect(store.nodes.value.get(2)).to.equal(undefined);
 		expect(store.nodes.value.get(3)).to.equal(undefined);
 	});
+
+	it("should reset inspectData on clear()", () => {
+		const store = createStore();
+		store.inspectData.value = {
+			canSuspend: false,
+			context: null,
+			hooks: null,
+			id: 123,
+			key: null,
+			name: "Foo",
+			props: null,
+			state: null,
+			suspended: false,
+			type: 1,
+		};
+		store.clear();
+		expect(store.inspectData.value).to.equal(null);
+	});
 });
Repository: preactjs/preact-devtools
Pull request #439 (2022-11-19 17:09:54)

Improve version parsing for partial tags


Patch:
diff --git a/src/adapter/parse-semverish.ts b/src/adapter/parse-semverish.ts
index 1a91ca7..ffcb117 100644
--- a/src/adapter/parse-semverish.ts
+++ b/src/adapter/parse-semverish.ts
@@ -4,7 +4,7 @@ const PATCH = 3;
 const PRERELEASE = 5;
 const PRERELEASE_TAG = 5;
 const PRERELEASE_VERSION = 6;
-const REGEXP_SEMVERISH = /^(\d+)\.(\d+)\.(\d+)(-(.+)\.(\d+))?$/i;
+const REGEXP_SEMVERISH = /^(\d+)\.(\d+)\.(\d+)(-([\w_-]+)(?:\.(\d+))?)?$/i;
 
 /**
  * semver-ish parsing based on https://github.com/npm/node-semver/blob/master/semver.js
@@ -27,7 +27,10 @@ export default function parseSemverish(
 		if (match[PRERELEASE]) {
 			preRelease = {
 				tag: match[PRERELEASE_TAG],
-				version: +match[PRERELEASE_VERSION],
+				version:
+					match[PRERELEASE_VERSION] !== undefined
+						? +match[PRERELEASE_VERSION]
+						: -1,
 			};
 		}
 


Test patch:
diff --git a/src/adapter/parse-semverish.test.ts b/src/adapter/parse-semverish.test.ts
new file mode 100644
index 0000000..9abf461
--- /dev/null
+++ b/src/adapter/parse-semverish.test.ts
@@ -0,0 +1,58 @@
+import parseSemverish from "./parse-semverish";
+import { expect } from "chai";
+
+describe("parse-semverish", () => {
+	it("should parse normal", () => {
+		expect(parseSemverish("10.0.1")).to.deep.equal({
+			major: 10,
+			minor: 0,
+			patch: 1,
+			preRelease: undefined,
+		});
+	});
+
+	it("should parse big numbers", () => {
+		expect(parseSemverish("10.10.10")).to.deep.equal({
+			major: 10,
+			minor: 10,
+			patch: 10,
+			preRelease: undefined,
+		});
+	});
+
+	it("should parse tags", () => {
+		expect(parseSemverish("10.2.3-alpha.0")).to.deep.equal({
+			major: 10,
+			minor: 2,
+			patch: 3,
+			preRelease: {
+				tag: "alpha",
+				version: 0,
+			},
+		});
+	});
+
+	it("should parse incomplete tags", () => {
+		expect(parseSemverish("10.2.3-alpha")).to.deep.equal({
+			major: 10,
+			minor: 2,
+			patch: 3,
+			preRelease: {
+				tag: "alpha",
+				version: -1,
+			},
+		});
+	});
+
+	it("should parse tags with dash", () => {
+		expect(parseSemverish("10.2.3-alpha-hehe.2")).to.deep.equal({
+			major: 10,
+			minor: 2,
+			patch: 3,
+			preRelease: {
+				tag: "alpha-hehe",
+				version: 2,
+			},
+		});
+	});
+});