nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: octokit/webhooks.js
Pull request #626 (2021-09-03 07:29:57)

feat: export emitterEventNames
`emitterEventNames` is a list of possible webhook event names that is useful e.g.: in GUI or validation of input. Therefore, it is very useful also outside of Octokit. Hence it has been exported.

This PR fixes: https://github.com/octokit/webhooks/issues/550



Patch:
diff --git a/README.md b/README.md
index 6ade67d..8cdc296 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,7 @@
   - [webhooks.removeListener()](#webhooksremovelistener)
   - [createNodeMiddleware()](#createnodemiddleware)
   - [Webhook events](#webhook-events)
+  - [emitterEventNames](#emittereventnames)
 - [TypeScript](#typescript)
   - [`EmitterWebhookEventName`](#emitterwebhookeventname)
   - [`EmitterWebhookEvent`](#emitterwebhookevent)
@@ -95,6 +96,7 @@ source.onmessage = (event) => {
 9. [webhooks.removeListener()](#webhooksremovelistener)
 10. [createNodeMiddleware()](#createnodemiddleware)
 11. [Webhook events](#webhook-events)
+12. [emitterEventNames](#emittereventnames)
 
 ### Constructor
 
@@ -694,6 +696,15 @@ If there are actions for a webhook, events are emitted for both, the webhook nam
 
 <!-- /autogenerated via scripts/generate-types.ts -->
 
+### emitterEventNames
+
+A read only tuple containing all the possible combinations of the webhook events + actions listed above. This might be useful in GUI and input validation.
+
+```js
+import { emitterEventNames } from "@octokit/webhooks";
+emitterEventNames; // ["check_run", "check_run.completed", ...]
+```
+
 ## TypeScript
 
 The types for the webhook payloads are sourced from [`@octokit/webhooks-types`](https://github.com/octokit/webhooks/tree/master/payload-types),
diff --git a/src/index.ts b/src/index.ts
index 427e62c..6cadf6b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -16,6 +16,7 @@ import {
 } from "./types";
 
 export { createNodeMiddleware } from "./middleware/node/index";
+export { emitterEventNames } from "./generated/webhook-names";
 
 // U holds the return value of `transform` function in Options
 class Webhooks<TTransformed = unknown> {


Test patch:
diff --git a/test/integration/smoke-test.ts b/test/integration/smoke-test.ts
index 1c53459..987290d 100644
--- a/test/integration/smoke-test.ts
+++ b/test/integration/smoke-test.ts
@@ -1,4 +1,4 @@
-import { Webhooks, createEventHandler } from "../../src";
+import { Webhooks, createEventHandler, emitterEventNames } from "../../src";
 
 test("@octokit/webhooks", () => {
   const emitWarningSpy = jest.spyOn(process, "emitWarning");
@@ -23,3 +23,9 @@ test('require("@octokit/webhooks").createEventHandler', () => {
   }).not.toThrow();
   expect(emitWarningSpy).not.toHaveBeenCalled();
 });
+
+test('require("@octokit/webhooks").emitterEventNames', () => {
+  const allEvents = emitterEventNames;
+  expect(typeof allEvents).toBe("object");
+  expect(typeof allEvents[0]).toBe("string");
+});
Repository: octokit/webhooks.js
Pull request #741 (2022-09-11 14:08:11)

tests: fix jest errors
Fixes test failures introduced in #732

wolfy1339: @octokit/js-community We will need to double check all the `octokit` repos to make sure that the inline snapshots are corrected.

Patch:
diff --git a/jest.config.ts b/jest.config.ts
index e1072d2..374644b 100644
--- a/jest.config.ts
+++ b/jest.config.ts
@@ -10,12 +10,14 @@ const config: Config.InitialOptions = {
       lines: 100,
     },
   },
-  globals: {
-    "ts-jest": {
-      tsconfig: {
-        esModuleInterop: true,
-      },
-    },
+  transform: {
+    "^.+\\.tsx?$": ["ts-jest",
+      {
+        tsconfig: {
+          esModuleInterop: true,
+        },
+      }
+    ],
   },
   preset: "ts-jest",
   restoreMocks: true,


Test patch:
diff --git a/test/integration/event-handler-test.ts b/test/integration/event-handler-test.ts
index 7f10db2..90b21f2 100644
--- a/test/integration/event-handler-test.ts
+++ b/test/integration/event-handler-test.ts
@@ -57,7 +57,7 @@ test("events", async () => {
   });
 
   expect(hooksCalled).toMatchInlineSnapshot(`
-    Array [
+    [
       "hook2",
       "* (push)",
       "hook1",
Repository: octokit/webhooks.js
Pull request #915 (2023-11-14 21:31:22)

fix: Handle verify error 


Patch:
diff --git a/src/verify-and-receive.ts b/src/verify-and-receive.ts
index 2ff4a34..2e4921d 100644
--- a/src/verify-and-receive.ts
+++ b/src/verify-and-receive.ts
@@ -14,7 +14,7 @@ export async function verifyAndReceive(
     state.secret,
     event.payload,
     event.signature
-  );
+  ).catch(() => false);
 
   if (!matchesSignature) {
     const error = new Error(


Test patch:
diff --git a/test/integration/node-middleware.test.ts b/test/integration/node-middleware.test.ts
index 1d5621f..ec819b3 100644
--- a/test/integration/node-middleware.test.ts
+++ b/test/integration/node-middleware.test.ts
@@ -605,4 +605,51 @@ describe("createNodeMiddleware(webhooks)", () => {
 
     server.close();
   });
+
+  test("Handles invalid signature", async () => {
+    expect.assertions(3);
+
+    const webhooks = new Webhooks({
+      secret: "mySecret",
+    });
+
+    webhooks.onError((error) => {
+      expect(error.message).toContain(
+        "signature does not match event payload and secret"
+      );
+    });
+
+    const log = {
+      debug: jest.fn(),
+      info: jest.fn(),
+      warn: jest.fn(),
+      error: jest.fn(),
+    };
+    const middleware = createNodeMiddleware(webhooks, { log });
+    const server = createServer(middleware).listen();
+
+    // @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
+    const { port } = server.address();
+
+    const response = await fetch(
+      `http://localhost:${port}/api/github/webhooks`,
+      {
+        method: "POST",
+        headers: {
+          "Content-Type": "application/json",
+          "X-GitHub-Delivery": "1",
+          "X-GitHub-Event": "push",
+          "X-Hub-Signature-256": "",
+        },
+        body: pushEventPayload,
+      }
+    );
+
+    expect(response.status).toEqual(400);
+    await expect(response.text()).resolves.toBe(
+      '{"error":"Error: [@octokit/webhooks] signature does not match event payload and secret"}'
+    );
+
+    server.close();
+  });
 });
Repository: octokit/webhooks.js
Pull request #916 (2023-11-14 22:12:13)

fix: Handle verify error


Patch:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index b8ec208..406d457 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -5,7 +5,7 @@ name: Release
       - main
       - next
       - beta
-      - v*.x
+      - "+([0-9]).x"
 jobs:
   release:
     name: release
diff --git a/src/verify-and-receive.ts b/src/verify-and-receive.ts
index 4b264c0..b45bb2c 100644
--- a/src/verify-and-receive.ts
+++ b/src/verify-and-receive.ts
@@ -20,7 +20,7 @@ export async function verifyAndReceive(
       ? toNormalizedJsonString(event.payload)
       : event.payload,
     event.signature
-  );
+  ).catch(() => false);
 
   if (!matchesSignature) {
     const error = new Error(


Test patch:
diff --git a/test/integration/node-middleware.test.ts b/test/integration/node-middleware.test.ts
index 4ecb70b..9f9e9d4 100644
--- a/test/integration/node-middleware.test.ts
+++ b/test/integration/node-middleware.test.ts
@@ -571,4 +571,51 @@ describe("createNodeMiddleware(webhooks)", () => {
 
     server.close();
   });
+
+  test("Handles invalid signature", async () => {
+    expect.assertions(3);
+
+    const webhooks = new Webhooks({
+      secret: "mySecret",
+    });
+
+    webhooks.onError((error) => {
+      expect(error.message).toContain(
+        "signature does not match event payload and secret"
+      );
+    });
+
+    const log = {
+      debug: jest.fn(),
+      info: jest.fn(),
+      warn: jest.fn(),
+      error: jest.fn(),
+    };
+    const middleware = createNodeMiddleware(webhooks, { log });
+    const server = createServer(middleware).listen();
+
+    // @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
+    const { port } = server.address();
+
+    const response = await fetch(
+      `http://localhost:${port}/api/github/webhooks`,
+      {
+        method: "POST",
+        headers: {
+          "Content-Type": "application/json",
+          "X-GitHub-Delivery": "1",
+          "X-GitHub-Event": "push",
+          "X-Hub-Signature-256": "",
+        },
+        body: pushEventPayload,
+      }
+    );
+
+    expect(response.status).toEqual(400);
+    await expect(response.text()).resolves.toBe(
+      '{"error":"Error: [@octokit/webhooks] signature does not match event payload and secret"}'
+    );
+
+    server.close();
+  });
 });
Repository: octokit/webhooks.js
Pull request #917 (2023-11-14 22:30:06)

fix: handles verify error


Patch:
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index da4bb06..bb23e62 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -5,7 +5,7 @@ on:
       - master
       - next
       - beta
-      - "v*.x" # maintenance release branches, e.g. v1.x
+      - "*.x" # maintenance release branches, e.g. 1.x
 jobs:
   release:
     name: release
diff --git a/src/verify-and-receive.ts b/src/verify-and-receive.ts
index 06a5944..5c99018 100644
--- a/src/verify-and-receive.ts
+++ b/src/verify-and-receive.ts
@@ -20,7 +20,7 @@ export async function verifyAndReceive(
       ? toNormalizedJsonString(event.payload)
       : event.payload,
     event.signature
-  );
+  ).catch(() => false);
 
   if (!matchesSignature) {
     const error = new Error(


Test patch:
diff --git a/test/integration/node-middleware.test.ts b/test/integration/node-middleware.test.ts
index 6af202c..411f26c 100644
--- a/test/integration/node-middleware.test.ts
+++ b/test/integration/node-middleware.test.ts
@@ -500,4 +500,51 @@ describe("createNodeMiddleware(webhooks)", () => {
 
     server.close();
   });
+
+  test("Handles invalid signature", async () => {
+    expect.assertions(3);
+
+    const webhooks = new Webhooks({
+      secret: "mySecret",
+    });
+
+    webhooks.onError((error) => {
+      expect(error.message).toContain(
+        "signature does not match event payload and secret"
+      );
+    });
+
+    const log = {
+      debug: jest.fn(),
+      info: jest.fn(),
+      warn: jest.fn(),
+      error: jest.fn(),
+    };
+    const middleware = createNodeMiddleware(webhooks, { log });
+    const server = createServer(middleware).listen();
+
+    // @ts-expect-error complains about { port } although it's included in returned AddressInfo interface
+    const { port } = server.address();
+
+    const response = await fetch(
+      `http://localhost:${port}/api/github/webhooks`,
+      {
+        method: "POST",
+        headers: {
+          "Content-Type": "application/json",
+          "X-GitHub-Delivery": "1",
+          "X-GitHub-Event": "push",
+          "X-Hub-Signature-256": "",
+        },
+        body: pushEventPayload,
+      }
+    );
+
+    expect(response.status).toEqual(400);
+    await expect(response.text()).resolves.toContain(
+      "Error: [@octokit/webhooks] signature does not match event payload and secret"
+    );
+
+    server.close();
+  });
 });
Repository: microsoft/vscode-edge-devtools
Pull request #188 (2020-08-12 23:00:04)

Fixing openEditor in simpleView.ts polyfill
This PR allows users to click on the mapped files and get the file open in vscode (broken behavior)

**Root cause:**
OpenEditor got broken due to changes in the InspectorHost module on the Devtools side.

**Fix:**
InspectorHost in no longer a global, instead it should be accessed through the legacy mechanism, which maps InspectorHost.Instance() to InspectorHost.




Patch:
diff --git a/src/host/polyfills/simpleView.ts b/src/host/polyfills/simpleView.ts
index e93d23b..f47990f 100644
--- a/src/host/polyfills/simpleView.ts
+++ b/src/host/polyfills/simpleView.ts
@@ -1,6 +1,6 @@
 // Copyright (c) Microsoft Corporation. All rights reserved.
 // Licensed under the MIT License.
-
+import { IDevToolsWindow } from "../host";
 import ToolsHost from "../toolsHost";
 
 declare var InspectorFrontendHost: {
@@ -17,7 +17,8 @@ interface IRevealable {
 
 export function revealInVSCode(revealable: IRevealable | undefined, omitFocus: boolean) {
     if (revealable && revealable.uiSourceCode && revealable.uiSourceCode._url) {
-        InspectorFrontendHost.InspectorFrontendHostInstance.openInEditor(
+        // using Devtools legacy mode.
+        (self as any as IDevToolsWindow).InspectorFrontendHost.openInEditor(
             revealable.uiSourceCode._url,
             revealable.lineNumber,
             revealable.columnNumber,


Test patch:
diff --git a/src/host/polyfills/simpleView.test.ts b/src/host/polyfills/simpleView.test.ts
index 8c6059f..7e7ee00 100644
--- a/src/host/polyfills/simpleView.test.ts
+++ b/src/host/polyfills/simpleView.test.ts
@@ -15,9 +15,7 @@ describe("simpleView", () => {
         };
         const mockOpen = jest.fn();
         (global as any).InspectorFrontendHost = {
-            InspectorFrontendHostInstance: {
                 openInEditor: mockOpen,
-            },
         };
 
         await apply.revealInVSCode(expected, expected.omitFocus);
Repository: microsoft/vscode-edge-devtools
Pull request #415 (2021-06-11 22:24:06)

[Feature]: Added ability to switch targets with DevTools open
This PR adds the feature to switch to another instance of the DevTools if one is currently open.

GIF:
![devtools-switching](https://user-images.githubusercontent.com/14304598/121754304-1dac4b00-cac9-11eb-8970-c5f2510a58b9.gif)



Patch:
diff --git a/src/devtoolsPanel.ts b/src/devtoolsPanel.ts
index f335769..59446e1 100644
--- a/src/devtoolsPanel.ts
+++ b/src/devtoolsPanel.ts
@@ -363,9 +363,12 @@ export class DevToolsPanel {
         config: IRuntimeConfig): void {
         const column = vscode.ViewColumn.Beside;
 
-        if (DevToolsPanel.instance) {
-            DevToolsPanel.instance.panel.reveal(column);
+        if (DevToolsPanel.instance && DevToolsPanel.instance.targetUrl === targetUrl) {
+                DevToolsPanel.instance.panel.reveal(column);
         } else {
+            if (DevToolsPanel.instance) {
+                DevToolsPanel.instance.dispose();
+            }
             const panel = vscode.window.createWebviewPanel(SETTINGS_STORE_NAME, SETTINGS_WEBVIEW_NAME, column, {
                 enableCommandUris: true,
                 enableScripts: true,


Test patch:
diff --git a/test/devtoolsPanel.test.ts b/test/devtoolsPanel.test.ts
index 92b777d..15b2df0 100644
--- a/test/devtoolsPanel.test.ts
+++ b/test/devtoolsPanel.test.ts
@@ -99,6 +99,16 @@ describe("devtoolsPanel", () => {
             expect(mockPanel.onDidDispose).toHaveBeenCalled();
         });
 
+        it("switches targets with active session", async () => {
+            const dtp = await import("../src/devtoolsPanel");
+            const mockVsCode = jest.requireMock("vscode");
+            
+            dtp.DevToolsPanel.createOrShow(context, mockTelemetry, "https://www.bing.com/", mockRuntimeConfig);
+            dtp.DevToolsPanel.createOrShow(context, mockTelemetry, "https://www.microsoft.com/", mockRuntimeConfig);
+            expect(mockPanel.onDidDispose).toHaveBeenCalledTimes(2);
+            expect(mockVsCode.window.createWebviewPanel).toHaveBeenCalledTimes(2);
+        });
+
         it("calls reveal on existing instance", async () => {
             const dtp = await import("../src/devtoolsPanel");
             dtp.DevToolsPanel.createOrShow(context, mockTelemetry, "", mockRuntimeConfig);
Repository: lo1tuma/eslint-plugin-mocha
Pull request #167 (2018-07-05 23:07:11)

Issue #166: No setup in describe hooks
Fixes issue #166 


Patch:
diff --git a/lib/rules/no-setup-in-describe.js b/lib/rules/no-setup-in-describe.js
index 7448c0f..d6aa739 100644
--- a/lib/rules/no-setup-in-describe.js
+++ b/lib/rules/no-setup-in-describe.js
@@ -13,7 +13,7 @@ module.exports = function noSetupInDescribe(context) {
     const settings = context.settings;
 
     function isPureNode(node) {
-        return astUtils.isHookIdentifier(node) || astUtils.isTestCase(node);
+        return astUtils.isHookCall(node) || astUtils.isTestCase(node);
     }
 
     function reportCallExpression(callExpression) {


Test patch:
diff --git a/test/rules/no-setup-in-describe.js b/test/rules/no-setup-in-describe.js
index 4141883..6fcb229 100644
--- a/test/rules/no-setup-in-describe.js
+++ b/test/rules/no-setup-in-describe.js
@@ -25,6 +25,11 @@ ruleTester.run('no-setup-in-describe', rule, {
         'describe("", function () { it("", function () { a["b"]; }); })',
         'describe("", function () { function a() { b(); }; it(); })',
         'describe("", function () { function a() { b.c; }; it(); })',
+        'describe("", function () { afterEach(function() { b(); }); it(); })',
+        {
+            code: 'describe("", function () { before(() => { b(); }); it(); })',
+            parserOptions: { ecmaVersion: 6 }
+        },
         { code: 'describe("", function () { var a = () => b(); it(); })', parserOptions: { ecmaVersion: 6 } },
         { code: 'describe("", function () { var a = () => b.c; it(); })', parserOptions: { ecmaVersion: 6 } },
         'describe("", function () { describe("", function () { it(); }); it(); })',
Repository: softlayer/softlayer-python
Pull request #1071 (2018-11-07 17:25:22)

NETWORK-8987 - added createDate and modifyDate parameters to sg rule-list
This adds the createDate and modifyDate parameters to the sg rule-list table under rule.py and to the mask under the get_securitygroup command under network.py.


Patch:
diff --git a/SoftLayer/CLI/securitygroup/rule.py b/SoftLayer/CLI/securitygroup/rule.py
index 4f624308..81526231 100644
--- a/SoftLayer/CLI/securitygroup/rule.py
+++ b/SoftLayer/CLI/securitygroup/rule.py
@@ -15,7 +15,9 @@
            'ethertype',
            'portRangeMin',
            'portRangeMax',
-           'protocol']
+           'protocol',
+           'createDate',
+           'modifyDate']
 
 
 @click.command()
@@ -49,7 +51,9 @@ def rule_list(env, securitygroup_id, sortby):
             rule.get('ethertype') or formatting.blank(),
             port_min,
             port_max,
-            rule.get('protocol') or formatting.blank()
+            rule.get('protocol') or formatting.blank(),
+            rule.get('createDate') or formatting.blank(),
+            rule.get('modifyDate') or formatting.blank()
         ])
 
     env.fout(table)
diff --git a/SoftLayer/managers/network.py b/SoftLayer/managers/network.py
index b568e889..4223143a 100644
--- a/SoftLayer/managers/network.py
+++ b/SoftLayer/managers/network.py
@@ -372,7 +372,7 @@ def get_securitygroup(self, group_id, **kwargs):
                 'description,'
                 '''rules[id, remoteIp, remoteGroupId,
                          direction, ethertype, portRangeMin,
-                         portRangeMax, protocol],'''
+                         portRangeMax, protocol, createDate, modifyDate],'''
                 '''networkComponentBindings[
                     networkComponent[
                         id,


Test patch:
diff --git a/tests/CLI/modules/securitygroup_tests.py b/tests/CLI/modules/securitygroup_tests.py
index 65c496b6..9b7e4c6a 100644
--- a/tests/CLI/modules/securitygroup_tests.py
+++ b/tests/CLI/modules/securitygroup_tests.py
@@ -118,7 +118,9 @@ def test_securitygroup_rule_list(self):
                            'remoteGroupId': None,
                            'protocol': None,
                            'portRangeMin': None,
-                           'portRangeMax': None}],
+                           'portRangeMax': None,
+                           'createDate': None,
+                           'modifyDate': None}],
                          json.loads(result.output))
 
     def test_securitygroup_rule_add(self):
Repository: softlayer/softlayer-python
Pull request #1076 (2018-11-16 22:32:52)

#1060 - bug in subnet list
basically just moved the click options around to make the new version of click happy. 


Patch:
diff --git a/SoftLayer/CLI/subnet/list.py b/SoftLayer/CLI/subnet/list.py
index e5d0d83a..508d649a 100644
--- a/SoftLayer/CLI/subnet/list.py
+++ b/SoftLayer/CLI/subnet/list.py
@@ -26,11 +26,10 @@
 @click.option('--identifier', help="Filter by network identifier")
 @click.option('--subnet-type', '-t', help="Filter by subnet type")
 @click.option('--network-space', help="Filter by network space")
-@click.option('--v4', '--ipv4', is_flag=True, help="Display only IPv4 subnets")
-@click.option('--v6', '--ipv6', is_flag=True, help="Display only IPv6 subnets")
+@click.option('--ipv4', '--v4', is_flag=True, help="Display only IPv4 subnets")
+@click.option('--ipv6', '--v6', is_flag=True, help="Display only IPv6 subnets")
 @environment.pass_env
-def cli(env, sortby, datacenter, identifier, subnet_type, network_space,
-        ipv4, ipv6):
+def cli(env, sortby, datacenter, identifier, subnet_type, network_space, ipv4, ipv6):
     """List subnets."""
 
     mgr = SoftLayer.NetworkManager(env.client)
diff --git a/SoftLayer/fixtures/SoftLayer_Account.py b/SoftLayer/fixtures/SoftLayer_Account.py
index 9b7b41da..891df9ec 100644
--- a/SoftLayer/fixtures/SoftLayer_Account.py
+++ b/SoftLayer/fixtures/SoftLayer_Account.py
@@ -316,9 +316,14 @@
     {
         'id': '100',
         'networkIdentifier': '10.0.0.1',
+        'cidr': '/24',
+        'networkVlanId': 123,
         'datacenter': {'name': 'dal00'},
         'version': 4,
-        'subnetType': 'PRIMARY'
+        'subnetType': 'PRIMARY',
+        'ipAddressCount': 10,
+        'virtualGuests': [],
+        'hardware': []
     }]
 
 getSshKeys = [{'id': '100', 'label': 'Test 1'},


Test patch:
diff --git a/tests/CLI/modules/subnet_tests.py b/tests/CLI/modules/subnet_tests.py
index b1b7e8f2..72825e0f 100644
--- a/tests/CLI/modules/subnet_tests.py
+++ b/tests/CLI/modules/subnet_tests.py
@@ -35,3 +35,7 @@ def test_detail(self):
                 'usable ips': 22
             },
             json.loads(result.output))
+
+    def test_list(self):
+        result = self.run_command(['subnet',  'list'])
+        self.assert_no_fail(result)