/
config-description.ts
65 lines (63 loc) · 2.03 KB
/
config-description.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { BranchStatus } from '../../../types';
import { emojify } from '../../../util/emoji';
import { resolveBranchStatus } from '../../branch/status-checks';
import type { BranchConfig } from '../../types';
export async function getPrConfigDescription(
config: BranchConfig
): Promise<string> {
let prBody = `\n\n---\n\n### Configuration\n\n`;
prBody += emojify(`:date: **Schedule**: `);
if (
config.schedule &&
(config.schedule as never) !== 'at any time' &&
config.schedule[0] !== 'at any time'
) {
prBody += `"${String(config.schedule)}"`;
if (config.timezone) {
prBody += ` in timezone ${config.timezone}.`;
} else {
prBody += ` (UTC).`;
}
} else {
prBody += 'At any time (no schedule defined).';
}
prBody += '\n\n';
prBody += emojify(':vertical_traffic_light: **Automerge**: ');
if (config.automerge) {
const branchStatus = await resolveBranchStatus(
config.branchName,
config.ignoreTests
);
// istanbul ignore if
if (branchStatus === BranchStatus.red) {
prBody += 'Disabled due to failing status checks.';
} else {
prBody += 'Enabled.';
}
} else {
prBody +=
'Disabled by config. Please merge this manually once you are satisfied.';
}
prBody += '\n\n';
prBody += emojify(':recycle: **Rebasing**: ');
if (config.rebaseWhen === 'behind-base-branch') {
prBody += 'Whenever PR is behind base branch';
} else if (config.rebaseWhen === 'never') {
prBody += 'Never';
} else {
prBody += 'Whenever PR becomes conflicted';
}
prBody += `, or you tick the rebase/retry checkbox.\n\n`;
if (config.recreateClosed) {
prBody += emojify(
`:ghost: **Immortal**: This PR will be recreated if closed unmerged. Get [config help](${config.productLinks.help}) if that's undesired.\n\n`
);
} else {
prBody += emojify(
`:no_bell: **Ignore**: Close this PR and you won't be reminded about ${
config.upgrades.length === 1 ? 'this update' : 'these updates'
} again.\n\n`
);
}
return prBody;
}