@@ -166,25 +166,22 @@ exports.IssueContentParser = void 0;
166
166
const utils_1 = __nccwpck_require__(918);
167
167
class IssueContentParser {
168
168
extractIssueTasklist(issue) {
169
- var _a, _b;
170
- const contentLines = (_b = (_a = issue.body) === null || _a === void 0 ? void 0 : _a.split("\n")) !== null && _b !== void 0 ? _b : [];
169
+ const contentLines = issue.body?.split("\n") ?? [];
171
170
return contentLines
172
171
.filter(x => this.isTaskListLine(x))
173
172
.map(x => (0, utils_1.parseIssueUrl)(x))
174
173
.filter((x) => x !== null);
175
174
}
176
175
extractIssueDependencies(issue) {
177
- var _a, _b;
178
- const contentLines = (_b = (_a = issue.body) === null || _a === void 0 ? void 0 : _a.split("\n")) !== null && _b !== void 0 ? _b : [];
176
+ const contentLines = issue.body?.split("\n") ?? [];
179
177
return contentLines
180
178
.filter(x => this.isDependencyLine(x))
181
179
.map(x => (0, utils_1.parseIssuesUrls)(x))
182
180
.flat()
183
181
.filter((x) => x !== null);
184
182
}
185
183
replaceIssueContent(issue, sectionTitle, newSectionContent) {
186
- var _a, _b;
187
- const contentLines = (_b = (_a = issue.body) === null || _a === void 0 ? void 0 : _a.split("\n")) !== null && _b !== void 0 ? _b : [];
184
+ const contentLines = issue.body?.split("\n") ?? [];
188
185
const sectionStartIndex = contentLines.findIndex(x => this.isMarkdownHeaderLine(x, sectionTitle));
189
186
if (sectionStartIndex === -1) {
190
187
throw new Error(`Markdown header '${sectionTitle}' is not found in issue body.`);
@@ -197,6 +194,16 @@ class IssueContentParser {
197
194
...contentLines.slice(sectionEndIndex !== -1 ? sectionEndIndex : contentLines.length),
198
195
].join("\n");
199
196
}
197
+ isIssueContentIdentical(issue, newIssueContent) {
198
+ // GitHub automatically replace "\n" to "\r\n" line endings when issue body is modified through GitHub UI.
199
+ // Replace "\r\n" to "\n" before comparing content to avoid unnecessary issue updates.
200
+ const rawIssueBody = issue.body ?? "";
201
+ const formattedIssueBody = rawIssueBody.replaceAll("\r\n", "\n");
202
+ const formattedNewIssueContent = newIssueContent.replaceAll("\r\n", "\n");
203
+ console.log(JSON.stringify(formattedIssueBody));
204
+ console.log(JSON.stringify(formattedNewIssueContent));
205
+ return formattedIssueBody === formattedNewIssueContent;
206
+ }
200
207
isMarkdownHeaderLine(str, sectionTitle) {
201
208
if (!str.startsWith("#")) {
202
209
return false;
@@ -290,6 +297,10 @@ const run = async () => {
290
297
core.startGroup("Updated root issue content");
291
298
core.info(updatedIssueContent);
292
299
core.endGroup();
300
+ if (issueContentParser.isIssueContentIdentical(rootIssue, updatedIssueContent)) {
301
+ core.info("Skipping update of root issue content because new content is identical to current content. No changes in mermaid in diagram.");
302
+ return;
303
+ }
293
304
if (inputs.dryRun) {
294
305
console.log("Action is run in dry-run mode. Root issue won't be updated");
295
306
return;
0 commit comments