nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: pactumjs/pactum
Pull request #359 (2024-05-29 07:19:38)

feat: use data management in object keys


Patch:
diff --git a/src/exports/stash.js b/src/exports/stash.js
index cd68a92..590c137 100644
--- a/src/exports/stash.js
+++ b/src/exports/stash.js
@@ -80,7 +80,6 @@ const stash = {
 
   getDataTemplate(path) {
     if (path) {
-      console.log(dataTemplate)
       return jq(path, { data: dataTemplate }).value;
     }
     return dataTemplate;
diff --git a/src/helpers/dataProcessor.js b/src/helpers/dataProcessor.js
index 5df6d27..8f72128 100644
--- a/src/helpers/dataProcessor.js
+++ b/src/helpers/dataProcessor.js
@@ -82,7 +82,14 @@ const dataProcessor = {
     }
     if (typeof data === 'object') {
       for (const prop in data) {
-        data[prop] = this.processDataRefs(data[prop]);
+        const updated_prop = this.getDataRefValue(prop);
+        if (typeof updated_prop === 'string' && updated_prop !== prop) {
+          data[updated_prop] = data[prop];
+          delete data[prop];
+          data[updated_prop] = this.processDataRefs(data[updated_prop]);
+        } else {
+          data[prop] = this.processDataRefs(data[prop]);
+        }
       }
     }
     return data;


Test patch:
diff --git a/test/unit/dataProcessor.spec.js b/test/unit/dataProcessor.spec.js
index 862a93a..ff887e5 100644
--- a/test/unit/dataProcessor.spec.js
+++ b/test/unit/dataProcessor.spec.js
@@ -398,7 +398,7 @@ describe('Data Processing - Templates - Direct Overrides', () => {
     });
     expect(config.data.template.enabled).equals(true);
     expect(config.data.template.processed).equals(true);
-  });  
+  });
 
 });
 
@@ -786,6 +786,26 @@ describe('Data Processing - Actual Data - Only Maps', () => {
     });
   });
 
+  it('processData - should replace object key with string', () => {
+    let data = {
+      '$M{User.Name}': 'Name'
+    };
+    data = dp.processData(data);
+    expect(data).deep.equals({
+      'Snow': 'Name'
+    });
+  });
+
+  it('processData - should not replace object key', () => {
+    let data = {
+      '$M{User}': 'Name'
+    };
+    data = dp.processData(data);
+    expect(data).deep.equals({
+      '$M{User}': 'Name'
+    });
+  });
+
   after(() => {
     stash.clearDataMaps();
   });
Repository: jamesramsay/hercule
Pull request #205 (2016-03-18 02:31:12)

Fix: aglio fallback syntax


Patch:
diff --git a/src/hercule.js b/src/hercule.js
index 0e002bf..a2ce5af 100644
--- a/src/hercule.js
+++ b/src/hercule.js
@@ -11,9 +11,9 @@ export const TranscludeStream = Transcluder;
 export function transcludeString(...args) {
   const input = args.shift();
   const cb = args.pop();
-  const [options, log, linkPaths] = args;
+  const [options, linkPaths] = args;
 
-  const transclude = new Transcluder(options, log, linkPaths);
+  const transclude = new Transcluder(options, linkPaths);
   let outputString = '';
   let cbErr = null;
 


Test patch:
diff --git a/test/units/transcludeFile.js b/test/units/transcludeFile.js
index ec81518..6fdc2b1 100644
--- a/test/units/transcludeFile.js
+++ b/test/units/transcludeFile.js
@@ -66,8 +66,8 @@ test.cb('should support tokenizer options', (t) => {
   const expected = 'Jackdaws love my\n\nbig\n\nsphinx\n\nof quartz.\n';
   const options = {
     relativePath: path.join(__dirname, '../fixtures/_aglio'),
-    linkRegExp: new RegExp(/(^[\t ]*)?(\:\[.*?\]\((.*?)\))|()( *<!-- include\((.*)\) -->)/gm),
-    linkMatch: (match) => match[3] || match[6],
+    linkRegExp: new RegExp(/(^[\t ]*)?(?:(\:\[.*?\]\((.*?)\))|(<!-- include\((.*?)\) -->))/gm),
+    linkMatch: (match) => match[3] || match[5],
   };
 
   transcludeFile(input, options, (err, output) => {
diff --git a/test/units/transcludeString.js b/test/units/transcludeString.js
index 3098883..0b08c34 100644
--- a/test/units/transcludeString.js
+++ b/test/units/transcludeString.js
@@ -35,17 +35,16 @@ test.cb('should provide pathList if variable provided', (t) => {
   });
 });
 
-test.cb('should support tokenizer options', (t) => {
-  const input = 'The quick brown fox jumps over the lazy dog.';
-  const expected = 'The quick brown fox jumps over the lazy dog.';
+test.cb('should return errors with tokenizer options', (t) => {
+  const input = '# Title\n<!-- include(test1.apib) -->\nSome content...\n';
   const options = {
-    linkRegExp: new RegExp(/(^[\t ]*)?(\:\[.*?\]\((.*?)\))|()( *<!-- include\((.*)\) -->)/gm),
-    linkMatch: (match) => match[3] || match[6],
+    linkRegExp: new RegExp(/(^[\t ]*)?(?:(\:\[.*?\]\((.*?)\))|(<!-- include\((.*?)\) -->))/gm),
+    linkMatch: (match) => match[3] || match[5],
   };
 
   transcludeString(input, options, (err, output) => {
-    t.same(err, null);
-    t.same(output, expected);
+    t.ok(err.message);
+    t.same(output, input);
     t.end();
   });
 });
Repository: jamesramsay/hercule
Pull request #39 (2015-07-15 00:18:21)

Fix empty reference extension
Fixed issue where empty extends (`:[empty extend link](file.md extend:"")` and :[empty extend link](file.md extend:)) would fail.


Patch:
diff --git a/src/hercule.coffee b/src/hercule.coffee
index 33e5f3c..2c244e6 100644
--- a/src/hercule.coffee
+++ b/src/hercule.coffee
@@ -25,8 +25,8 @@ transclude = (input, relativePath, parents, parentRefs, logger, cb) ->
     if not matchingReferences[0]? and hrefType is "file"
       href = path.join relativePath, href
 
-    href = overridingReference?.href || href
-    hrefType = overridingReference?.hrefType || hrefType
+    href = overridingReference.href if overridingReference?
+    hrefType = overridingReference.hrefType if overridingReference?
 
     if _.contains parents, href
       logger "#{href} is in parents:\n#{JSON.stringify parents}"


Test patch:
diff --git a/test/fixtures/test-extend/activity.md b/test/fixtures/test-extend/activity.md
index bbab4ff..f044369 100644
--- a/test/fixtures/test-extend/activity.md
+++ b/test/fixtures/test-extend/activity.md
@@ -1,1 +1,1 @@
-jumps over the :[state](state) :[animal](animal)
+jumps :[this should be removed](empty)over the :[state](state) :[animal](animal)
diff --git a/test/fixtures/test-extend/fox.md b/test/fixtures/test-extend/fox.md
index dfbc1d0..962e7f6 100644
--- a/test/fixtures/test-extend/fox.md
+++ b/test/fixtures/test-extend/fox.md
@@ -1,1 +1,1 @@
-The quick brown fox :[activity](activity.md animal:canine.md state:disinterest.md).
+The quick brown fox :[activity](activity.md animal:canine.md state:disinterest.md empty:).
Repository: jamesramsay/hercule
Pull request #60 (2015-11-10 21:56:05)

Don't hang if a transclusion couldn't be found
The current code fails to call `done()` if a transcluded file couldn't be found. It should simply fail to make the replacement and continue processing.


Patch:
diff --git a/src/hercule.coffee b/src/hercule.coffee
index 256ff1f..4f1ccb9 100644
--- a/src/hercule.coffee
+++ b/src/hercule.coffee
@@ -45,7 +45,7 @@ transclude = (input, relativePath, parents, parentRefs, logger, cb) ->
             .replace /\n$/, ""
 
           input = input.replace "#{placeholder}", output
-          return done()
+        return done()
   , ->
     return cb input
 


Test patch:
diff --git a/test/fixtures/test-default/missing-link.md b/test/fixtures/test-default/missing-link.md
new file mode 100644
index 0000000..f89295c
--- /dev/null
+++ b/test/fixtures/test-default/missing-link.md
@@ -0,0 +1,1 @@
+Jackdaws love my :[test link](non-existend-file.md) sphinx of quartz.
diff --git a/test/hercule.coffee b/test/hercule.coffee
index d351613..80ad54e 100644
--- a/test/hercule.coffee
+++ b/test/hercule.coffee
@@ -87,6 +87,15 @@ describe 'hercule', ->
         assert.equal output, 'Jackdaws love my imagined sphinx of quartz.\n'
         done()
 
+    it 'should transclude strings with invalid links without hanging', (done) ->
+      file = __dirname + "/fixtures/test-default/missing-link.md"
+      input = (fs.readFileSync file).toString()
+      dir = path.dirname file
+
+      hercule.transcludeString input, null, {relativePath: dir}, (output) ->
+        assert.equal output, 'Jackdaws love my :[test link](non-existend-file.md) sphinx of quartz.\n'
+        done()
+
 
   describe 'transcludeFile', ->