release-it 18.0.0-next.1 → 18.0.0-next.2

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.
@@ -1,10 +1,12 @@
1
1
  // Totally much borrowed from https://github.com/semantic-release/github/blob/master/lib/success.js
2
2
  import issueParser from 'issue-parser';
3
3
 
4
- const getSearchQueries = (base, commits, separator = '+') => {
4
+ export const getSearchQueries = (base, commits, separator = '+') => {
5
+ const encodedSeparator = encodeURIComponent(separator);
6
+
5
7
  return commits.reduce((searches, commit) => {
6
8
  const lastSearch = searches[searches.length - 1];
7
- if (lastSearch && lastSearch.length + commit.length <= 256 - separator.length) {
9
+ if (lastSearch && encodeURIComponent(lastSearch).length + commit.length <= 256 - encodedSeparator.length) {
8
10
  searches[searches.length - 1] = `${lastSearch}${separator}${commit}`;
9
11
  } else {
10
12
  searches.push(`${base}${separator}${commit}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "release-it",
3
- "version": "18.0.0-next.1",
3
+ "version": "18.0.0-next.2",
4
4
  "description": "Generic CLI tool to automate versioning and package publishing-related tasks.",
5
5
  "keywords": [
6
6
  "build",
@@ -125,7 +125,7 @@
125
125
  "prettier": "3.3.3",
126
126
  "remark-cli": "12.0.1",
127
127
  "remark-preset-webpro": "1.1.0",
128
- "sinon": "18.0.1",
128
+ "sinon": "19.0.0",
129
129
  "strip-ansi": "7.1.0",
130
130
  "typescript": "5.6.2"
131
131
  },
package/test/github.js CHANGED
@@ -2,6 +2,7 @@ import test from 'ava';
2
2
  import sinon from 'sinon';
3
3
  import { RequestError } from '@octokit/request-error';
4
4
  import GitHub from '../lib/plugin/github/GitHub.js';
5
+ import { getSearchQueries } from '../lib/plugin/github/util.js';
5
6
  import { factory, runTasks } from './util/index.js';
6
7
  import {
7
8
  interceptAuthentication,
@@ -485,3 +486,25 @@ test.skip('should truncate long body', async t => {
485
486
  t.is(releaseUrl, 'https://github.com/user/repo/releases/tag/2.0.2');
486
487
  exec.restore();
487
488
  });
489
+
490
+ test('should generate search queries correctly', t => {
491
+ const generateCommit = () => Math.random().toString(36).substring(2, 9);
492
+ const base = 'repo:owner/repo+type:pr+is:merged';
493
+ const commits = Array.from({ length: 5 }, generateCommit);
494
+ const separator = '+';
495
+
496
+ const result = getSearchQueries(base, commits, separator);
497
+
498
+ // Test case 1: Check if all commits are included in the search queries
499
+ const allCommitsIncluded = commits.every(commit => result.some(query => query.includes(commit)));
500
+ t.true(allCommitsIncluded, 'All commits should be included in the search queries');
501
+
502
+ // Test case 2: Check if the function respects the 256 character limit
503
+ const manyCommits = Array.from({ length: 100 }, generateCommit);
504
+ const longResult = getSearchQueries(base, manyCommits, separator);
505
+ t.true(longResult.length > 1, 'Many commits should be split into multiple queries');
506
+ t.true(
507
+ longResult.every(query => encodeURIComponent(query).length <= 256),
508
+ 'Each query should not exceed 256 characters after encoding'
509
+ );
510
+ });