mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-11 14:36:25 +00:00
fix(platform): smart truncate pr body (#4527)
This commit is contained in:
parent
bb56c364f6
commit
77a0291d4d
9 changed files with 237 additions and 36 deletions
|
@ -6,6 +6,7 @@ import GitStorage from '../git/storage';
|
|||
import { logger } from '../../logger';
|
||||
import { PlatformConfig, RepoParams, RepoConfig } from '../common';
|
||||
import { sanitize } from '../../util/sanitize';
|
||||
import { smartTruncate } from '../utils/pr-body';
|
||||
|
||||
interface Config {
|
||||
storage: GitStorage;
|
||||
|
@ -487,7 +488,7 @@ export async function mergePr(pr: number) {
|
|||
|
||||
export function getPrBody(input: string) {
|
||||
// Remove any HTML we use
|
||||
return input
|
||||
return smartTruncate(input, 4000)
|
||||
.replace(new RegExp(`\n---\n\n.*?<!-- ${appSlug}-rebase -->.*?\n`), '')
|
||||
.replace('<summary>', '**')
|
||||
.replace('</summary>', '**')
|
||||
|
|
|
@ -8,6 +8,7 @@ import GitStorage from '../git/storage';
|
|||
import { logger } from '../../logger';
|
||||
import { PlatformConfig, RepoParams, RepoConfig } from '../common';
|
||||
import { sanitize } from '../../util/sanitize';
|
||||
import { smartTruncate } from '../utils/pr-body';
|
||||
|
||||
/*
|
||||
* Version: 5.3 (EOL Date: 15 Aug 2019)
|
||||
|
@ -952,12 +953,11 @@ export async function mergePr(prNo: number, branchName: string) {
|
|||
export function getPrBody(input: string) {
|
||||
logger.debug(`getPrBody(${input.split('\n')[0]})`);
|
||||
// Remove any HTML we use
|
||||
return input
|
||||
return smartTruncate(input, 30000)
|
||||
.replace(/<\/?summary>/g, '**')
|
||||
.replace(/<\/?details>/g, '')
|
||||
.replace(new RegExp(`\n---\n\n.*?<!-- .*?-rebase -->.*?(\n|$)`), '')
|
||||
.replace(new RegExp('<!--.*?-->', 'g'), '')
|
||||
.substring(0, 30000);
|
||||
.replace(new RegExp('<!--.*?-->', 'g'), '');
|
||||
}
|
||||
|
||||
export function getCommitMessages() {
|
||||
|
|
|
@ -10,6 +10,7 @@ import { appSlug } from '../../config/app-strings';
|
|||
import * as comments from './comments';
|
||||
import { PlatformConfig, RepoParams, RepoConfig } from '../common';
|
||||
import { sanitize } from '../../util/sanitize';
|
||||
import { smartTruncate } from '../utils/pr-body';
|
||||
|
||||
let config: utils.Config = {} as any;
|
||||
|
||||
|
@ -694,12 +695,11 @@ export async function mergePr(prNo: number, branchName: string) {
|
|||
|
||||
export function getPrBody(input: string) {
|
||||
// Remove any HTML we use
|
||||
return input
|
||||
return smartTruncate(input, 50000)
|
||||
.replace(/<\/?summary>/g, '**')
|
||||
.replace(/<\/?details>/g, '')
|
||||
.replace(new RegExp(`\n---\n\n.*?<!-- ${appSlug}-rebase -->.*?\n`), '')
|
||||
.replace(/\]\(\.\.\/pull\//g, '](../../pull-requests/')
|
||||
.substring(0, 50000);
|
||||
.replace(/\]\(\.\.\/pull\//g, '](../../pull-requests/');
|
||||
}
|
||||
|
||||
// Return the commit SHA for a branch
|
||||
|
|
|
@ -16,6 +16,7 @@ import {
|
|||
urls,
|
||||
} from '../../config/app-strings';
|
||||
import { sanitize } from '../../util/sanitize';
|
||||
import { smartTruncate } from '../utils/pr-body';
|
||||
|
||||
const defaultConfigFile = configFileNames[0];
|
||||
|
||||
|
@ -1711,39 +1712,16 @@ export async function mergePr(prNo: number, branchName: string) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// istanbul ignore next
|
||||
function smartTruncate(input: string) {
|
||||
if (input.length < 60000) {
|
||||
return input;
|
||||
}
|
||||
const releaseNotesMatch = input.match(
|
||||
new RegExp(`### Release Notes.*### ${appName} configuration`, 'ms')
|
||||
);
|
||||
// istanbul ignore if
|
||||
if (releaseNotesMatch) {
|
||||
const divider = `</details>\n\n---\n\n### ${appName} configuration`;
|
||||
const [releaseNotes] = releaseNotesMatch;
|
||||
const nonReleaseNotesLength =
|
||||
input.length - releaseNotes.length - divider.length;
|
||||
const availableLength = 60000 - nonReleaseNotesLength;
|
||||
return input.replace(
|
||||
releaseNotes,
|
||||
releaseNotes.slice(0, availableLength) + divider
|
||||
);
|
||||
}
|
||||
return input.substring(0, 60000);
|
||||
}
|
||||
|
||||
export function getPrBody(input: string) {
|
||||
if (config.isGhe) {
|
||||
return smartTruncate(input);
|
||||
return smartTruncate(input, 60000);
|
||||
}
|
||||
const massagedInput = input
|
||||
// to be safe, replace all github.com links with renovatebot redirector
|
||||
.replace(/href="https?:\/\/github.com\//g, 'href="https://togithub.com/')
|
||||
.replace(/]\(https:\/\/github\.com\//g, '](https://togithub.com/')
|
||||
.replace(/]: https:\/\/github\.com\//g, ']: https://togithub.com/');
|
||||
return smartTruncate(massagedInput);
|
||||
return smartTruncate(massagedInput, 60000);
|
||||
}
|
||||
|
||||
export async function getVulnerabilityAlerts() {
|
||||
|
|
|
@ -8,6 +8,7 @@ import { PlatformConfig, RepoParams, RepoConfig } from '../common';
|
|||
import { configFileNames } from '../../config/app-strings';
|
||||
import { logger } from '../../logger';
|
||||
import { sanitize } from '../../util/sanitize';
|
||||
import { smartTruncate } from '../utils/pr-body';
|
||||
|
||||
const defaultConfigFile = configFileNames[0];
|
||||
let config: {
|
||||
|
@ -830,10 +831,13 @@ export async function mergePr(iid: number) {
|
|||
}
|
||||
|
||||
export function getPrBody(input: string) {
|
||||
return input
|
||||
.replace(/Pull Request/g, 'Merge Request')
|
||||
.replace(/PR/g, 'MR')
|
||||
.replace(/\]\(\.\.\/pull\//g, '](../merge_requests/');
|
||||
return smartTruncate(
|
||||
input
|
||||
.replace(/Pull Request/g, 'Merge Request')
|
||||
.replace(/PR/g, 'MR')
|
||||
.replace(/\]\(\.\.\/pull\//g, '](../merge_requests/'),
|
||||
1000000
|
||||
);
|
||||
}
|
||||
|
||||
export function getCommitMessages() {
|
||||
|
|
23
lib/platform/utils/pr-body.ts
Normal file
23
lib/platform/utils/pr-body.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { appName } from '../../config/app-strings';
|
||||
|
||||
export function smartTruncate(input: string, len: number): string {
|
||||
if (input.length < len) {
|
||||
return input;
|
||||
}
|
||||
const releaseNotesMatch = input.match(
|
||||
new RegExp(`### Release Notes.*### ${appName} configuration`, 'ms')
|
||||
);
|
||||
if (releaseNotesMatch) {
|
||||
const divider = `</details>\n\n---\n\n### ${appName} configuration`;
|
||||
const [releaseNotes] = releaseNotesMatch;
|
||||
const nonReleaseNotesLength =
|
||||
input.length - releaseNotes.length - divider.length;
|
||||
const availableLength = len - nonReleaseNotesLength;
|
||||
if (availableLength <= 0) return input.substring(0, len);
|
||||
return input.replace(
|
||||
releaseNotes,
|
||||
releaseNotes.slice(0, availableLength) + divider
|
||||
);
|
||||
}
|
||||
return input.substring(0, len);
|
||||
}
|
60
test/platform/utils/__snapshots__/pr-body.spec.ts.snap
Normal file
60
test/platform/utils/__snapshots__/pr-body.spec.ts.snap
Normal file
|
@ -0,0 +1,60 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`platform/utils/pr-body .smartTruncate truncates to 300 not smart 1`] = `
|
||||
"This PR contains the following updates:
|
||||
|
||||
| Package | Type | Update | Change |
|
||||
|---|---|---|---|
|
||||
| [renovate/renovate](https://togithub.com/renovatebot/renovate) | final | minor | \`19.46.0-slim\` -> \`19.47.0-slim\` |
|
||||
|
||||
---
|
||||
|
||||
### Release Notes
|
||||
|
||||
<details>
|
||||
<summary>renovatebot/renovate</summary>
|
||||
|
||||
### [\`v19."
|
||||
`;
|
||||
|
||||
exports[`platform/utils/pr-body .smartTruncate truncates to 1000 1`] = `
|
||||
"This PR contains the following updates:
|
||||
|
||||
| Package | Type | Update | Change |
|
||||
|---|---|---|---|
|
||||
| [renovate/renovate](https://togithub.com/renovatebot/renovate) | final | minor | \`19.46.0-slim\` -> \`19.47.0-slim\` |
|
||||
|
||||
---
|
||||
|
||||
### Release Notes
|
||||
|
||||
<details>
|
||||
<summary>renovatebot/renovate</summary>
|
||||
|
||||
### [\`v19.47.0\`](https://togithub.com/renovatebot/renovate/releases/19.47.0)
|
||||
|
||||
##### Features
|
||||
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togi</details>
|
||||
|
||||
---
|
||||
|
||||
### Renovate configuration
|
||||
|
||||
:date: **Schedule**: At any time (no schedule defined).
|
||||
|
||||
:vertical_traffic_light: **Automerge**: Enabled.
|
||||
|
||||
:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with \\"\`rebase!\`\\".
|
||||
|
||||
:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.
|
||||
|
||||
---
|
||||
|
||||
- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box
|
||||
|
||||
---
|
||||
|
||||
This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#VisualOn/docker-images).
|
||||
"
|
||||
`;
|
101
test/platform/utils/_fixtures/pr-body.txt
Normal file
101
test/platform/utils/_fixtures/pr-body.txt
Normal file
|
@ -0,0 +1,101 @@
|
|||
This PR contains the following updates:
|
||||
|
||||
| Package | Type | Update | Change |
|
||||
|---|---|---|---|
|
||||
| [renovate/renovate](https://togithub.com/renovatebot/renovate) | final | minor | `19.46.0-slim` -> `19.47.0-slim` |
|
||||
|
||||
---
|
||||
|
||||
### Release Notes
|
||||
|
||||
<details>
|
||||
<summary>renovatebot/renovate</summary>
|
||||
|
||||
### [`v19.47.0`](https://togithub.com/renovatebot/renovate/releases/19.47.0)
|
||||
|
||||
##### Features
|
||||
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
- **docker:** AWS ECR authentication support ([#​4497](https://togithub.com/renovatebot/renovate/issues/4497)) ([acb114a](https://togithub.com/renovatebot/renovate/commit/acb114a))
|
||||
|
||||
</details>
|
||||
|
||||
---
|
||||
|
||||
### Renovate configuration
|
||||
|
||||
:date: **Schedule**: At any time (no schedule defined).
|
||||
|
||||
:vertical_traffic_light: **Automerge**: Enabled.
|
||||
|
||||
:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".
|
||||
|
||||
:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.
|
||||
|
||||
---
|
||||
|
||||
- [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box
|
||||
|
||||
---
|
||||
|
||||
This PR has been generated by [Renovate Bot](https://togithub.com/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#VisualOn/docker-images).
|
34
test/platform/utils/pr-body.spec.ts
Normal file
34
test/platform/utils/pr-body.spec.ts
Normal file
|
@ -0,0 +1,34 @@
|
|||
import fs from 'fs-extra';
|
||||
import { smartTruncate } from '../../../lib/platform/utils/pr-body';
|
||||
|
||||
describe('platform/utils/pr-body', () => {
|
||||
let prBody: string;
|
||||
beforeAll(async () => {
|
||||
prBody = await fs.readFile(
|
||||
'test/platform/utils/_fixtures/pr-body.txt',
|
||||
'utf8'
|
||||
);
|
||||
});
|
||||
describe('.smartTruncate', () => {
|
||||
it('truncates to 1000', () => {
|
||||
const body = smartTruncate(prBody, 1000);
|
||||
expect(body).toMatchSnapshot();
|
||||
expect(body.length < prBody.length).toEqual(true);
|
||||
});
|
||||
|
||||
it('truncates to 300 not smart', () => {
|
||||
const body = smartTruncate(prBody, 300);
|
||||
expect(body).toMatchSnapshot();
|
||||
expect(body.length).toEqual(300);
|
||||
});
|
||||
|
||||
it('truncates to 10', () => {
|
||||
const body = smartTruncate('Lorem ipsum dolor sit amet', 10);
|
||||
expect(body).toEqual('Lorem ipsu');
|
||||
});
|
||||
|
||||
it('does not truncate', () => {
|
||||
expect(smartTruncate(prBody, 60000)).toEqual(prBody);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue