Skip to content

Commit

Permalink
optional chaning
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Panayil <[email protected]>
  • Loading branch information
sachin-panayil committed Nov 27, 2024
1 parent 7b15a6f commit 95a8d2e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
12 changes: 7 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,12 +454,12 @@ exports.default = getConfig;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getFileChanges = void 0;
function getFileChanges(jsonResult) {
var _a;
var _a, _b;
try {
const data = JSON.parse(jsonResult);
const files = {};
for (const result of data.results) {
if ((_a = result.lintResult.message) === null || _a === void 0 ? void 0 : _a.startsWith("Did not find")) {
if ((_b = (_a = result.lintResult) === null || _a === void 0 ? void 0 : _a.message) === null || _b === void 0 ? void 0 : _b.startsWith("Did not find")) {
const fileName = result.ruleInfo.ruleConfig['file-name'];
const content = result.ruleInfo.ruleConfig['file-content'] || '';
if (fileName) {
Expand Down Expand Up @@ -572,15 +572,17 @@ function getRunNumber() {
function getPRBody(result) {
const content = repolinter_1.markdownFormatter.formatOutput(result, true);
return `
### General Guidance
# General Guidance
This text is going to be some guidance on what to do now that you have a PR. \n
You can either push as is or combine what you have already or do something else. \n
For sure have to think of best language for this. \n
The raw results of the repolinter can be found below. \n

---

<details>
<summary>
### Repolinter Results
Repolinter Results
</summary>

${content}
Expand Down Expand Up @@ -689,7 +691,7 @@ function run(disableRetry) {
const pr = yield octokit.createPullRequest({
owner,
repo,
title: `Repolinter Results - #${RUN_NUMBER}`,
title: `Repolinter Results`,
body: getPRBody(result),
base: BASE_BRANCH || "main",
head: `repolinter-results-#${RUN_NUMBER}`,
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/getFileChanges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ interface RepolinterResult {
};
};
status: string;
lintResult: {
message: string;
lintResult?: {
message?: string;
};
}>;
}
Expand All @@ -19,7 +19,7 @@ export function getFileChanges(jsonResult: string): { [key: string]: string } {
const files: { [key: string]: string } = {};

for (const result of data.results) {
if (result.lintResult.message?.startsWith("Did not find")) {
if (result.lintResult?.message?.startsWith("Did not find")) {
const fileName = result.ruleInfo.ruleConfig['file-name'];
const content = result.ruleInfo.ruleConfig['file-content'] || '';

Expand Down
8 changes: 5 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ function getRunNumber(): number {
function getPRBody(result: LintResult): string {
const content = markdownFormatter.formatOutput(result, true)
return `
### General Guidance
# General Guidance
This text is going to be some guidance on what to do now that you have a PR. \n
You can either push as is or combine what you have already or do something else. \n
For sure have to think of best language for this. \n
The raw results of the repolinter can be found below. \n
---
<details>
<summary>
### Repolinter Results
Repolinter Results
</summary>
${content}
Expand Down Expand Up @@ -171,7 +173,7 @@ export default async function run(disableRetry?: boolean): Promise<void> {
const pr = await octokit.createPullRequest({
owner,
repo,
title: `Repolinter Results - #${RUN_NUMBER}`,
title: `Repolinter Results`,
body: getPRBody(result),
base: BASE_BRANCH || "main",
head: `repolinter-results-#${RUN_NUMBER}`,
Expand Down

0 comments on commit 95a8d2e

Please sign in to comment.