From bd6e0a92daf107b4c32e9dbc4df2987de2427ab5 Mon Sep 17 00:00:00 2001 From: Jamie Nelson Date: Sun, 11 Oct 2026 07:57:55 +1100 Subject: [PATCH 1/2] refactor: remove unused wrapping and branch discovery helpers --- src/helpers.ts | 84 -------------------------------------------------- 1 file changed, 84 deletions(-) diff --git a/src/helpers.ts b/src/helpers.ts index 4f16f585..548a1d55 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -88,59 +88,6 @@ export function prefixParser(text: string | undefined): string | undefined { return titlecase(text.replace(/[_-]+/, ' ')); } -/** - * Wraps the given text into multiple lines with a maximum width of 80 characters. - * @param text - The text to wrap. - * @param content - The array to store the wrapped lines. - * @param prepend - The string to prepend to each wrapped line. - * @returns The array of wrapped lines. - */ -export function wrapText( - text: string | undefined, - content: string[], - prepend: string = '', -): string[] { - // Constrain the width of the description - if (!text) { - return content; - } - const width = 80; - - let description = text - .trim() - .replaceAll('\r\n', '\n') // Convert CR to LF - .replaceAll(/ +/g, ' ') // Squash consecutive spaces - .replaceAll(' \n', '\n'); // Squash space followed by newline - - while (description) { - // Longer than width? Find a space to break apart - let segment: string; - if (description.length > width) { - segment = description.slice(0, Math.max(0, width + 1)); - while (!segment.endsWith(' ') && !segment.endsWith('\n') && segment) { - segment = segment.slice(0, Math.max(0, segment.length - 1)); - } - - // Trimmed too much? - if (segment.length < width * 0.67) { - segment = description; - } - } else { - segment = description; - } - - // Check for newline - const newlineIndex = segment.indexOf('\n'); - if (newlineIndex >= 0) { - segment = segment.slice(0, Math.max(0, newlineIndex + 1)); - } - content.push(`${prepend}${segment}`.trimEnd()); - // Remaining - description = description.slice(segment.length); - } - return content; -} - /** * Represents a repository with owner and repo properties. */ @@ -283,37 +230,6 @@ export function repositoryFinder( throw new Error('No owner or repo found'); } -/** - * Returns the default branch of the git repository. - * @returns The default branch. - */ -/** - * Gets the default branch for the Git repository. - * - * @returns The name of the default branch. - */ -export function getDefaultGitBranch(): string { - let result: Buffer | undefined; - try { - // Run git command to get default branch - result = execSync('git symbolic-ref HEAD | sed s@^refs/heads/@@'); - } catch (error) { - // If command fails, try alternative for MacOS - if (error) { - try { - result = execSync( - "git remote set-head origin -a;git remote show origin | head 50 sed -n 's/^.*default branch \\(.*\\)/\\1/p'", - ); - } catch { - result = execSync( - "git remote set-head origin -a;git remote show origin | sed -n 's/^s*HEAD branch: \\(.*\\)/\\1/p'", - ); - } - } - } - return result?.toString().trim() ?? ''; -} - /** * Formats the given value as a column header. * @param value - The value to format. From 058d7e8890783ff36db255156e0ed11dc8659749 Mon Sep 17 00:00:00 2001 From: Jamie Nelson Date: Sun, 11 Oct 2026 07:57:57 +1100 Subject: [PATCH 2/2] test: remove tests of deleted unused helper --- __tests__/helpers.test.ts | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/__tests__/helpers.test.ts b/__tests__/helpers.test.ts index 1ec008f8..e395e560 100644 --- a/__tests__/helpers.test.ts +++ b/__tests__/helpers.test.ts @@ -17,7 +17,6 @@ import { stripRefs, titlecase, undefinedOnEmpty, - wrapText, } from '../src/helpers.js'; import type Inputs from '../src/inputs.js'; import { @@ -193,40 +192,6 @@ describe('helpers', () => { }); }); - describe('wrapText', () => { - it('should return the content array if the text is empty', () => { - const content = ['line 1', 'line 2']; - const result = wrapText('', content); - expect(result).toEqual(content); - }); - - it('should wrap the text into multiple lines with a maximum width of 80 characters', () => { - const content: string[] = []; - const result = wrapText( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod ultricies mi, nec convallis nisi. Donec pulvinar vestibulum tellus, in posuere ex. Sed eget semper ipsum.', - content, - ); - expect(result).toEqual([ - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod ultricies', - 'mi, nec convallis nisi. Donec pulvinar vestibulum tellus, in posuere ex. Sed', - 'eget semper ipsum.', - ]); - }); - - it('should prepend the given string to each wrapped line', () => { - const content: string[] = []; - const result = wrapText( - 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod ultricies mi, nec convallis nisi.', - content, - '> ', - ); - expect(result).toEqual([ - '> Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed euismod ultricies', - '> mi, nec convallis nisi.', - ]); - }); - }); - describe('rowHeader', () => { it('should return empty string if the value is empty', () => { expect(rowHeader('')).toBe('');