-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
Copy pathindex.ts
37 lines (34 loc) · 1.03 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import * as p from '../../../util/promises';
import {
containsTemplates,
exposedConfigOptions,
} from '../../../util/template';
import type { BranchUpgradeConfig } from '../../types';
import { getChangeLogJSON } from '../update/pr/changelog';
export async function embedChangelog(
upgrade: BranchUpgradeConfig
): Promise<void> {
// getChangeLogJSON returns null on error, so don't try again
if (upgrade.logJSON !== undefined) {
return;
}
upgrade.logJSON = await getChangeLogJSON(upgrade);
}
export async function embedChangelogs(
branches: BranchUpgradeConfig[]
): Promise<void> {
await p.map(branches, embedChangelog, { concurrency: 10 });
}
export function needsChangelogs(
upgrade: BranchUpgradeConfig,
fields = exposedConfigOptions.filter((o) => o !== 'commitBody')
): boolean {
// commitBody is now compiled when commit is done
for (const field of fields) {
// fields set by `getChangeLogJSON`
if (containsTemplates(upgrade[field], ['logJSON', 'releases'])) {
return true;
}
}
return false;
}