92
92
await exec.exec("git", ["config", "user.name", "TypeScript Bot"]);
93
93
await exec.exec("git", ["switch", "--detach", `origin/${TARGET_BRANCH}`]);
94
94
await exec.exec("git", ["switch", "-c", pickBranch]);
95
- await exec.exec("git", ["cherry-pick", "-m", "1", pr.data.merge_commit_sha]);
95
+
96
+ let updatedBaselinesMessage = "";
97
+ try {
98
+ await exec.exec("git", ["cherry-pick", "-m", "1", pr.data.merge_commit_sha]);
99
+ } catch (e) {
100
+ console.log(e);
101
+
102
+ // The cherry-pick failed. If all of the conflicts are in tests/baselines,
103
+ // try to run the tests and accept the new baselines.
104
+
105
+ await exec.exec("git", ["add", "tests/baselines"]);
106
+ // This will fail if any other files were modified.
107
+ await exec.exec("git", ["-c", "core.editor=true", "cherry-pick", "--continue"]);
108
+
109
+ await exec.exec("npm", ["ci"]);
110
+
111
+ try {
112
+ await exec.exec("npm", ["test", "--", "--no-lint"]);
113
+ } catch {
114
+ // Expected to fail.
115
+ }
116
+
117
+ await exec.exec("npx", ["hereby", "baseline-accept"]);
118
+ await exec.exec("git", ["add", "tests/baselines"]);
119
+ await exec.exec("git", ["commit", "-m", "Update baselines"]);
120
+
121
+ updatedBaselinesMessage = " This involved updating baselines; please check the diff.";
122
+ }
123
+
96
124
await exec.exec("git", ["push", "--force", "--set-upstream", "origin", pickBranch]);
97
125
98
126
const existingPulls = await github.rest.pulls.list({
@@ -106,7 +134,7 @@ jobs:
106
134
if (existingPulls.data.length === 0) {
107
135
console.log(`No existing PRs found for ${pickBranch}`);
108
136
109
- const body = `This cherry-pick was triggered by a request on #${PR}.\n\nPlease review the diff and merge if no changes are unexpected.`;
137
+ const body = `This cherry-pick was triggered by a request on #${PR}.\n\nPlease review the diff and merge if no changes are unexpected.${updatedBaselinesMessage} `;
110
138
111
139
const newPr = await github.rest.pulls.create({
112
140
owner: context.repo.owner,
@@ -131,7 +159,7 @@ jobs:
131
159
reviewers: ["DanielRosenwasser", REQUESTING_USER],
132
160
});
133
161
134
- commentBody = `I've created #${newPr.data.number} for you.`;
162
+ commentBody = `I've created #${newPr.data.number} for you.${updatedBaselinesMessage} `;
135
163
}
136
164
else {
137
165
const existing = existingPulls.data[0];
@@ -144,7 +172,7 @@ jobs:
144
172
title,
145
173
});
146
174
147
- commentBody = `I've updated #${existing.number} for you.`;
175
+ commentBody = `I've updated #${existing.number} for you.${updatedBaselinesMessage} `;
148
176
}
149
177
150
178
return commentBody;
0 commit comments