nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: abuiles/ember-watson
Pull request #69 (2015-07-28 05:55:34)

fix watson:methodify command to ensure app path gets defaulted correctly
closes https://github.com/abuiles/ember-watson/issues/68

marcioj: Looks good. Can you also add a test in [commands-test.js](https://github.com/abuiles/ember-watson/blob/master/tests/commands-test.js) ?

Patch:
diff --git a/lib/commands/methodify.js b/lib/commands/methodify.js
index e83a2bc..e481c13 100644
--- a/lib/commands/methodify.js
+++ b/lib/commands/methodify.js
@@ -11,7 +11,7 @@ module.exports = {
     '<path>'
   ],
   run: function(commandOptions, rawArgs) {
-    var path = rawArgs || 'app';
+    var path = rawArgs[0] || 'app';
     watson.transformMethodify(path);
   }
 };


Test patch:
diff --git a/tests/commands-test.js b/tests/commands-test.js
index def4add..81102ba 100644
--- a/tests/commands-test.js
+++ b/tests/commands-test.js
@@ -8,6 +8,7 @@ var transformEmberDataAsyncFalseRelationshipsCalledWith;
 var transformPrototypeExtensionsCalledWith;
 var transformQUnitTestCalledWith;
 var transformResourceRouterMappingCalledWith;
+var transformMethodifyCalledWith;
 
 proxyquire('../lib/commands/convert-ember-data-model-lookups', {
   '../../index': Mock
@@ -29,6 +30,10 @@ proxyquire('../lib/commands/convert-resource-router-mapping', {
   '../../index': Mock
 });
 
+proxyquire('../lib/commands/methodify', {
+  '../../index': Mock
+});
+
 function Mock() {}
 
 Mock.prototype.transformEmberDataModelLookups = function() {
@@ -51,6 +56,10 @@ Mock.prototype.transformResourceRouterMapping = function () {
   transformResourceRouterMappingCalledWith = Array.prototype.slice.apply(arguments);
 };
 
+Mock.prototype.transformMethodify = function () {
+  transformMethodifyCalledWith = Array.prototype.slice.apply(arguments);
+};
+
 describe('Commands:', function () {
 
   afterEach(function () {
@@ -59,6 +68,7 @@ describe('Commands:', function () {
     transformPrototypeExtensionsCalledWith = null;
     transformQUnitTestCalledWith = null;
     transformResourceRouterMappingCalledWith = null;
+    transformMethodifyCalledWith = null;
   });
 
   it('convert-ember-data-model-lookups calls the correct transform', function () {
@@ -116,4 +126,14 @@ describe('Commands:', function () {
       ['other-router']
     );
   });
+
+  it('methodify calls the correct transform', function () {
+    var Command = require('../lib/commands/methodify');
+
+    Command.run({}, []);
+    assert.deepEqual(transformMethodifyCalledWith, ['app']);
+
+    Command.run({}, ['some-app']);
+    assert.deepEqual(transformMethodifyCalledWith, ['some-app']);
+  });
 });
Repository: lucasbento/create-graphql
Pull request #62 (2017-02-06 18:58:33)

fix interface generation


Patch:
diff --git a/packages/generator/src/type/templates/Type.js.template b/packages/generator/src/type/templates/Type.js.template
index 63057e5..ba47de3 100644
--- a/packages/generator/src/type/templates/Type.js.template
+++ b/packages/generator/src/type/templates/Type.js.template
@@ -16,6 +16,6 @@ export default new GraphQLObjectType({
       description: 'My example field',
       resolve: obj => obj.example,
     },
-    interfaces: () => [NodeInterface],
   }),
-});
\ No newline at end of file
+  interfaces: () => [NodeInterface],
+});
diff --git a/packages/generator/src/type/templates/TypeWithSchema.js.template b/packages/generator/src/type/templates/TypeWithSchema.js.template
index 86219a7..5d60fdf 100644
--- a/packages/generator/src/type/templates/TypeWithSchema.js.template
+++ b/packages/generator/src/type/templates/TypeWithSchema.js.template
@@ -28,6 +28,6 @@ export default new GraphQLObjectType({
       resolve: <%if(field.resolveArgs){%><%=field.resolveArgs%><%}else{ %>obj<%} %> => <%= field.resolve %>,
     },
     <%_ } -%>
-    interfaces: () => [NodeInterface],
   }),
+  interfaces: () => [NodeInterface],
 });


Test patch:
diff --git a/packages/generator/src/type/__tests__/__snapshots__/TypeGenerator.spec.js.snap b/packages/generator/src/type/__tests__/__snapshots__/TypeGenerator.spec.js.snap
index b0345d5..c741613 100644
--- a/packages/generator/src/type/__tests__/__snapshots__/TypeGenerator.spec.js.snap
+++ b/packages/generator/src/type/__tests__/__snapshots__/TypeGenerator.spec.js.snap
@@ -18,9 +18,10 @@ export default new GraphQLObjectType({
       description: \'My example field\',
       resolve: obj => obj.example,
     },
-    interfaces: () => [NodeInterface],
   }),
-});",
+  interfaces: () => [NodeInterface],
+});
+",
   "typeTest": "import { graphql } from \'graphql\';
 import { schema } from \'../../schema\';
 import { setupTest } from \'../../../../test/helper\';
@@ -102,8 +103,8 @@ export default new GraphQLObjectType({
       description: \'\',
       resolve: obj => obj.updatedAt.toISOString(),
     },
-    interfaces: () => [NodeInterface],
   }),
+  interfaces: () => [NodeInterface],
 });
 ",
   "typeTest": "import { graphql } from \'graphql\';
@@ -181,8 +182,8 @@ export default new GraphQLObjectType({
       description: \'\',
       resolve: obj => obj.active,
     },
-    interfaces: () => [NodeInterface],
   }),
+  interfaces: () => [NodeInterface],
 });
 ",
   "typeTest": "import { graphql } from \'graphql\';
Repository: pinojs/pino
Pull request #1066 (2021-07-11 20:02:16)

Replace fast-safe-stringify with json-stringify-safe
Fixes https://github.com/pinojs/pino/issues/1062


Patch:
diff --git a/lib/tools.js b/lib/tools.js
index 1bebeed..296e135 100644
--- a/lib/tools.js
+++ b/lib/tools.js
@@ -5,7 +5,7 @@
 const format = require('quick-format-unescaped')
 const { mapHttpRequest, mapHttpResponse } = require('pino-std-serializers')
 const SonicBoom = require('sonic-boom')
-const stringifySafe = require('fast-safe-stringify')
+const stringifySafe = require('json-stringify-safe')
 const {
   lsCacheSym,
   chindingsSym,
@@ -437,7 +437,11 @@ function stringify (obj) {
   try {
     return JSON.stringify(obj)
   } catch (_) {
-    return stringifySafe(obj)
+    try {
+      return stringifySafe(obj)
+    } catch (_) {
+      return '"[unable to serialize, circular reference is too complex to analyze]"'
+    }
   }
 }
 
diff --git a/package.json b/package.json
index 2f2534e..b19aed8 100644
--- a/package.json
+++ b/package.json
@@ -104,6 +104,7 @@
     "on-exit-leak-free": "^0.1.0",
     "pino-abstract-transport": "^0.2.0",
     "pino-std-serializers": "^4.0.0",
+    "json-stringify-safe": "^5.0.1",
     "quick-format-unescaped": "^4.0.3",
     "sonic-boom": "^2.1.0",
     "thread-stream": "^0.11.0"


Test patch:
diff --git a/test/basic.test.js b/test/basic.test.js
index 8828edc..27c4b37 100644
--- a/test/basic.test.js
+++ b/test/basic.test.js
@@ -593,8 +593,7 @@ test('children with same names render in correct order', async ({ equal }) => {
   equal(a, 3, 'last logged object takes precedence')
 })
 
-// https://github.com/pinojs/pino/pull/251 - use this.stringify
-test('use `fast-safe-stringify` to avoid circular dependencies', async ({ same }) => {
+test('use `json-stringify-safe` to avoid circular dependencies', async ({ same }) => {
   const stream = sink()
   const root = pino(stream)
   // circular depth
@@ -602,10 +601,10 @@ test('use `fast-safe-stringify` to avoid circular dependencies', async ({ same }
   obj.a = obj
   root.info(obj)
   const { a } = await once(stream, 'data')
-  same(a, { a: '[Circular]' })
+  same(a, { a: '[Circular ~]' })
 })
 
-test('fast-safe-stringify must be used when interpolating', async (t) => {
+test('json-stringify-safe must be used when interpolating', async (t) => {
   const stream = sink()
   const instance = pino(stream)
 
@@ -614,7 +613,7 @@ test('fast-safe-stringify must be used when interpolating', async (t) => {
   instance.info('test %j', o)
 
   const { msg } = await once(stream, 'data')
-  t.equal(msg, 'test {"a":{"b":{"c":"[Circular]"}}}')
+  t.equal(msg, 'test {"a":{"b":{"c":"[Circular ~.a.b]"}}}')
 })
 
 test('throws when setting useOnlyCustomLevels without customLevels', async ({ throws }) => {
Repository: pinojs/pino
Pull request #1122 (2021-09-08 10:40:11)

Deprecate the prettyPrint option
Fixes https://github.com/pinojs/pino/issues/1106


Patch:
diff --git a/docs/api.md b/docs/api.md
index 697a22a..ec357fd 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -347,6 +347,8 @@ and searching for logged objects can start from a consistent path.
 
 Default: `false`
 
+__DEPRECATED: use [`transport`](#transport) instead.
+
 Enables pretty printing log logs. This is intended for non-production
 configurations. This may be set to a configuration object as outlined in the
 [`pino-pretty` documentation](https://github.com/pinojs/pino-pretty).
@@ -934,11 +936,7 @@ const pino = require('pino')
 const transports = pino.transport({
   targets: [{
     level: 'info',
-    target: 'some-transport',
-    options: { some: 'options for', the: 'transport' }
-  }, {
-    level: 'info',
-    target: 'pino-pretty'
+    target: 'pino-pretty' // must be installed separately
   }, {
     level: 'trace',
     target: 'pino/file',
diff --git a/lib/deprecations.js b/lib/deprecations.js
index 4c8f0a5..5d09ee6 100644
--- a/lib/deprecations.js
+++ b/lib/deprecations.js
@@ -12,3 +12,5 @@ warning.create(warnName, 'PINODEP005', 'bindings.formatters is deprecated, use o
 warning.create(warnName, 'PINODEP006', 'bindings.customLevels is deprecated, use options.customLevels option instead')
 
 warning.create(warnName, 'PINODEP007', 'bindings.level is deprecated, use options.level option instead')
+
+warning.create(warnName, 'PINODEP008', 'prettyPrint is deprecated, use the pino-pretty transport instead')
diff --git a/lib/tools.js b/lib/tools.js
index c3502a9..a238c19 100644
--- a/lib/tools.js
+++ b/lib/tools.js
@@ -6,6 +6,7 @@ const format = require('quick-format-unescaped')
 const { mapHttpRequest, mapHttpResponse } = require('pino-std-serializers')
 const SonicBoom = require('sonic-boom')
 const stringifySafe = require('json-stringify-safe')
+const warning = require('./deprecations')
 const {
   lsCacheSym,
   chindingsSym,
@@ -419,6 +420,7 @@ function createArgsNormalizer (defaultOptions) {
       stream = buildSafeSonicBoom({ fd: stream.fd, sync: true })
     }
     if (prettyPrint) {
+      warning.emit('PINODEP008')
       const prettyOpts = Object.assign({ messageKey }, prettyPrint)
       stream = getPrettyStream(prettyOpts, prettifier, stream, instance)
     }


Test patch:
diff --git a/test/pretty.test.js b/test/pretty.test.js
index b44e627..3fe30af 100644
--- a/test/pretty.test.js
+++ b/test/pretty.test.js
@@ -9,6 +9,22 @@ const { once } = require('./helper')
 const pino = require('../')
 const strip = require('strip-ansi')
 
+// silence warnings
+process.removeAllListeners('warning')
+
+// This test MUST be the first
+test('deprecation', ({ equal, plan }) => {
+  plan(1)
+
+  process.once('warning', function (warning) {
+    equal(warning.code, 'PINODEP008')
+  })
+
+  pino({
+    prettyPrint: true
+  })
+})
+
 test('can be enabled via exported pino function', async ({ not }) => {
   let actual = ''
   const child = execa(process.argv[0], [join(__dirname, 'fixtures', 'pretty', 'basic.js')])
Repository: pinojs/pino
Pull request #1335 (2022-02-15 12:51:31)

Refactor the mixing logic


Patch:
diff --git a/lib/proto.js b/lib/proto.js
index ae00e38..1eca123 100644
--- a/lib/proto.js
+++ b/lib/proto.js
@@ -164,19 +164,23 @@ function write (_obj, msg, num) {
   let obj
 
   if (_obj === undefined || _obj === null) {
-    obj = mixin ? mixin({}) : {}
+    obj = {}
   } else if (_obj instanceof Error) {
-    obj = Object.assign(mixin ? mixin({}) : {}, { err: _obj })
+    obj = { err: _obj }
     if (msg === undefined) {
       msg = _obj.message
     }
   } else {
-    obj = Object.assign(mixin ? mixin({}) : {}, _obj)
+    obj = _obj
     if (msg === undefined && _obj.err) {
       msg = _obj.err.message
     }
   }
 
+  if (mixin) {
+    obj = Object.assign(mixin(obj), obj)
+  }
+
   const s = this[asJsonSym](obj, msg, num, t)
 
   const stream = this[streamSym]


Test patch:
diff --git a/test/mixin.test.js b/test/mixin.test.js
index ced8ef0..cac37e9 100644
--- a/test/mixin.test.js
+++ b/test/mixin.test.js
@@ -102,12 +102,16 @@ test('mixin not a function', async ({ throws }) => {
   })
 })
 
-test('mixin can use context', async ({ ok }) => {
+test('mixin can use context', async ({ ok, same }) => {
   const stream = sink()
   const instance = pino({
     mixin (context) {
       ok(context !== null, 'context should be defined')
       ok(context !== undefined, 'context should be defined')
+      same(context, {
+        message: '123',
+        stack: 'stack'
+      })
       return Object.assign({
         error: context.message,
         stack: context.stack
@@ -121,12 +125,13 @@ test('mixin can use context', async ({ ok }) => {
   }, 'test')
 })
 
-test('mixin works without context', async ({ ok }) => {
+test('mixin works without context', async ({ ok, same }) => {
   const stream = sink()
   const instance = pino({
     mixin (context) {
       ok(context !== null, 'context is still defined w/o passing mergeObject')
       ok(context !== undefined, 'context is still defined w/o passing mergeObject')
+      same(context, {})
       return {
         something: true
       }
Repository: pinojs/pino
Pull request #1362 (2022-03-08 16:45:26)

fix: Throw when using custom level formatters with multiple transports (#1353)
This PR aim to fix an [issue](https://github.com/pinojs/pino/issues/1353) where if the user is using a custom level formatter and multiple transports at the same time logs will not be written and the user will not be notified.

Instead of failing silently the new behavior is to throw an error when both options are used at the same time (as mentioned [here](https://github.com/pinojs/pino/issues/1353#issuecomment-1059203373))


Patch:
diff --git a/docs/api.md b/docs/api.md
index 1557094..0c27d08 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -293,6 +293,8 @@ Changes the shape of the log level. The default shape is `{ level: number }`.
 The function takes two arguments, the label of the level (e.g. `'info'`)
 and the numeric value (e.g. `30`).
 
+ps: The log level cannot be customized when using multiple transports
+
 ```js
 const formatters = {
   level (label, number) {
diff --git a/lib/tools.js b/lib/tools.js
index 97c5f21..91df051 100644
--- a/lib/tools.js
+++ b/lib/tools.js
@@ -409,6 +409,9 @@ function createArgsNormalizer (defaultOptions) {
       if (opts.transport instanceof SonicBoom || opts.transport.writable || opts.transport._writableState) {
         throw Error('option.transport do not allow stream, please pass to option directly. e.g. pino(transport)')
       }
+      if (opts.transport.targets && opts.transport.targets.length && opts.formatters && typeof opts.formatters.level === 'function') {
+        throw Error('option.transport.targets do not allow custom level formatters')
+      }
       stream = transport({ caller, ...opts.transport })
     }
     opts = Object.assign({}, defaultOptions, opts)


Test patch:
diff --git a/test/formatters.test.js b/test/formatters.test.js
index 354a880..75d05cd 100644
--- a/test/formatters.test.js
+++ b/test/formatters.test.js
@@ -335,3 +335,30 @@ test('formatter with transport', async ({ match, equal }) => {
     nested: { object: true }
   })
 })
+
+test('throws when custom level formatter is used with transport.targets', async ({ throws }) => {
+  const destination = join(
+    os.tmpdir(),
+    '_' + Math.random().toString(36).substr(2, 9)
+  )
+
+  throws(() => {
+    pino({
+      formatters: {
+        level (label) {
+          return label
+        }
+      },
+      transport: {
+        targets: [
+          {
+            target: 'pino/file',
+            options: { destination }
+          }
+        ]
+      }
+    }
+    )
+  },
+  Error('option.transport.targets do not allow custom level formatters'))
+})