@node-core/utils 6.3.2 → 6.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/landing_session.js +34 -25
- package/npm-shrinkwrap.json +8582 -16
- package/package.json +2 -2
package/lib/landing_session.js
CHANGED
|
@@ -316,40 +316,49 @@ export default class LandingSession extends Session {
|
|
|
316
316
|
|
|
317
317
|
// git has very specific rules about what is a trailer and what is not.
|
|
318
318
|
// Instead of trying to implement those ourselves, let git parse the
|
|
319
|
-
//
|
|
320
|
-
const
|
|
319
|
+
// commit message and see if it outputs any trailers.
|
|
320
|
+
const interpretTrailers = commitMessage => runSync('git', [
|
|
321
321
|
'interpret-trailers', '--parse', '--no-divider'
|
|
322
322
|
], {
|
|
323
|
-
input: `${
|
|
324
|
-
})
|
|
325
|
-
const separatorIndex = trailer.indexOf(':');
|
|
326
|
-
return [trailer.slice(0, separatorIndex), trailer.slice(separatorIndex + 2)];
|
|
327
|
-
}).slice(0, -1); // Remove the last line return entry
|
|
323
|
+
input: `${commitMessage}\n`
|
|
324
|
+
});
|
|
328
325
|
|
|
326
|
+
const originalTrailers = interpretTrailers(original);
|
|
329
327
|
const containCVETrailer = CVE_RE.test(originalTrailers);
|
|
330
328
|
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
329
|
+
const amended = original.trim().split('\n');
|
|
330
|
+
let keptTrailers = [];
|
|
331
|
+
if (originalTrailers) {
|
|
332
|
+
const stillInTrailers = () => {
|
|
333
|
+
const result = interpretTrailers(amended.join('\n'));
|
|
334
|
+
return result.length && originalTrailers.startsWith(result.trim());
|
|
335
|
+
};
|
|
336
|
+
// Remove all lines until we find an empty string, which should get of all
|
|
337
|
+
// trailers in most cases.
|
|
338
|
+
amended.splice(amended.lastIndexOf(''), Infinity);
|
|
339
|
+
for (let i = amended.length - 1; amended[i] === '' || stillInTrailers(); i--) {
|
|
340
|
+
// Remove last line until git no longer detects any trailers
|
|
341
|
+
amended.pop();
|
|
342
|
+
}
|
|
341
343
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
344
|
+
// Only keep existing trailers that we won't add ourselves
|
|
345
|
+
const trailersToFilterOut = ['BACKPORT-PR-URL', 'REVIEWED-BY'];
|
|
346
|
+
if (!this.backport) trailersToFilterOut.push('PR-URL');
|
|
347
|
+
keptTrailers = originalTrailers
|
|
348
|
+
.split('\n')
|
|
349
|
+
.map(trailer => {
|
|
350
|
+
const separatorIndex = trailer.indexOf(':');
|
|
351
|
+
return [trailer.slice(0, separatorIndex), trailer.slice(separatorIndex + 2)];
|
|
352
|
+
})
|
|
353
|
+
.slice(0, -1) // Remove the last line return entry
|
|
354
|
+
.filter(
|
|
355
|
+
([key]) => !trailersToFilterOut.includes(key.toUpperCase())
|
|
356
|
+
);
|
|
357
|
+
}
|
|
348
358
|
amended.push('', ...keptTrailers.map(([key, value]) => `${key}: ${value}`));
|
|
349
359
|
|
|
350
360
|
for (const line of metadata.trim().split('\n')) {
|
|
351
|
-
|
|
352
|
-
if (foundMatchingTrailer && line === foundMatchingTrailer.join(': ')) {
|
|
361
|
+
if (keptTrailers.some((trailer) => line.toUpperCase() === trailer.join(': ').toUpperCase())) {
|
|
353
362
|
cli.warn(`Found ${line}, skipping..`);
|
|
354
363
|
continue;
|
|
355
364
|
}
|