generated from actions/container-toolkit-action
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from Renato66/feat/parse-body-and-title
Feat/parse body and title
- Loading branch information
Showing
9 changed files
with
98 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { expect, describe, test } from 'bun:test' | ||
import { parseText } from './parseText' | ||
|
||
describe('getIssueLabels function', () => { | ||
test('should return just scoped body', () => { | ||
const body = | ||
'Body with labels <!-- AUTO-LABEL:START --> Label1 Label2 <!-- AUTO-LABEL:END -->' | ||
const result = parseText(body, '', false, false) | ||
|
||
expect(result).toEqual(' --> Label1 Label2 <!-- ') | ||
}) | ||
|
||
test('should return just scoped body', () => { | ||
const body = 'Body with labels <!-- Label3 --> Label1 Label2' | ||
const result = parseText(body, '', true, false) | ||
|
||
expect(result).toEqual('Body with labels Label1 Label2') | ||
}) | ||
|
||
test('should return just scoped body', () => { | ||
const body = 'Body with labels <!-- Label3 --> Label1 Label2' | ||
const result = parseText(body, 'Title', true, true) | ||
|
||
expect(result).toEqual('Title Body with labels Label1 Label2') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
export const parseText = ( | ||
body: string, | ||
title: string, | ||
ignoreComments?: boolean, | ||
includeTitle?: boolean | ||
): string => { | ||
let parsedBody = body | ||
if (parsedBody.includes('AUTO-LABEL:START')) { | ||
const [_ignore, ...bodySplit] = body.split('AUTO-LABEL:START') | ||
parsedBody = bodySplit | ||
.map((elem) => elem.split('AUTO-LABEL:END')[0]) | ||
.join(' ') | ||
} | ||
|
||
if (ignoreComments && parsedBody.includes('<!--')) { | ||
parsedBody = parsedBody.replace(/\<!--(.|\n)*?-->/g, '') | ||
} | ||
|
||
const response = [parsedBody] | ||
|
||
if (includeTitle) { | ||
response.unshift(title) | ||
} | ||
|
||
return response.join(' ') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters