@@ -166,25 +166,22 @@ exports.IssueContentParser = void 0;
166166const utils_1 = __nccwpck_require__(918);
167167class IssueContentParser {
168168 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") ?? [];
171170 return contentLines
172171 .filter(x => this.isTaskListLine(x))
173172 .map(x => (0, utils_1.parseIssueUrl)(x))
174173 .filter((x) => x !== null);
175174 }
176175 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") ?? [];
179177 return contentLines
180178 .filter(x => this.isDependencyLine(x))
181179 .map(x => (0, utils_1.parseIssuesUrls)(x))
182180 .flat()
183181 .filter((x) => x !== null);
184182 }
185183 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") ?? [];
188185 const sectionStartIndex = contentLines.findIndex(x => this.isMarkdownHeaderLine(x, sectionTitle));
189186 if (sectionStartIndex === -1) {
190187 throw new Error(`Markdown header '${sectionTitle}' is not found in issue body.`);
@@ -197,6 +194,16 @@ class IssueContentParser {
197194 ...contentLines.slice(sectionEndIndex !== -1 ? sectionEndIndex : contentLines.length),
198195 ].join("\n");
199196 }
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+ }
200207 isMarkdownHeaderLine(str, sectionTitle) {
201208 if (!str.startsWith("#")) {
202209 return false;
@@ -290,6 +297,10 @@ const run = async () => {
290297 core.startGroup("Updated root issue content");
291298 core.info(updatedIssueContent);
292299 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+ }
293304 if (inputs.dryRun) {
294305 console.log("Action is run in dry-run mode. Root issue won't be updated");
295306 return;
0 commit comments