Skip to content

Commit

Permalink
Enable comment again
Browse files Browse the repository at this point in the history
  • Loading branch information
rehlma committed Apr 12, 2024
1 parent 4061bc9 commit 94e5de4
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 36 deletions.
34 changes: 18 additions & 16 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29076,20 +29076,22 @@ function run() {
}
return;
}
const editIssueId = core.getInput('edit-issue-id');
if (editIssueId) {
console.log('Edit issue id:', editIssueId);
return;
else {
const editIssueId = core.getInput('edit-issue-id');
if (editIssueId) {
console.log('Edit issue id:', editIssueId);
return;
}
const pr = github.context.payload.pull_request;
if (!pr) {
throw new Error('This action can only be run on pull requests');
}
const prDiff = yield getPrDiff(octokit, pr.base.sha, pr.head.sha);
const todos = findTodos(prDiff);
console.log('Todos:', JSON.stringify(todos));
const useOutput = core.getInput('use-output');
yield commentPr(octokit, pr.number, todos);
}
// const pr = github.context.payload.pull_request
// if (!pr) {
// throw new Error('This action can only be run on pull requests')
// }
// const prDiff = await getPrDiff(octokit, pr.base.sha, pr.head.sha)
// const todos = findTodos(prDiff)
// console.log('Todos:', JSON.stringify(todos))
// const useOutput = core.getInput('use-output')
// await commentPr(octokit, pr.number, todos)
}
catch (error) {
if (error instanceof Error) {
Expand Down Expand Up @@ -29154,7 +29156,7 @@ function findTodos(prDiff) {
}
exports.findTodos = findTodos;
function getTodoIfFound(line) {
const regex = /[/*#]+.*(TODO.*)/i;
const regex = /[/*#]+.*(TODO.*|FIXME.*)/i;
const matches = [...line.matchAll(regex)];
if (matches === undefined || matches.length === 0)
return;
Expand All @@ -29173,7 +29175,7 @@ function commentPr(octokit, prNumber, todos) {
const addedTodos = todo.todos.filter(todo => todo.added);
const removedTodos = todo.todos.filter(todo => !todo.added);
for (const innerTodo of addedTodos) {
let response = yield octokit.rest.pulls.createReviewComment({
yield octokit.rest.pulls.createReviewComment({
owner,
repo,
pull_number: prNumber,
Expand All @@ -29185,7 +29187,7 @@ function commentPr(octokit, prNumber, todos) {
});
}
for (const innerTodo of removedTodos) {
let response = yield octokit.rest.pulls.createReviewComment({
yield octokit.rest.pulls.createReviewComment({
owner,
repo,
pull_number: prNumber,
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,25 +69,25 @@ export async function run(): Promise<void> {
console.log('Error creating commit status', error)
}
return
}

const editIssueId = core.getInput('edit-issue-id')
if (editIssueId) {
console.log('Edit issue id:', editIssueId)
return
}
} else {
const editIssueId = core.getInput('edit-issue-id')
if (editIssueId) {
console.log('Edit issue id:', editIssueId)
return
}

// const pr = github.context.payload.pull_request
// if (!pr) {
// throw new Error('This action can only be run on pull requests')
// }
// const prDiff = await getPrDiff(octokit, pr.base.sha, pr.head.sha)
const pr = github.context.payload.pull_request
if (!pr) {
throw new Error('This action can only be run on pull requests')
}
const prDiff = await getPrDiff(octokit, pr.base.sha, pr.head.sha)

// const todos = findTodos(prDiff)
// console.log('Todos:', JSON.stringify(todos))
const todos = findTodos(prDiff)
console.log('Todos:', JSON.stringify(todos))

// const useOutput = core.getInput('use-output')
// await commentPr(octokit, pr.number, todos)
const useOutput = core.getInput('use-output')

Check failure on line 88 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'useOutput' is assigned a value but never used

Check failure on line 88 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'useOutput' is assigned a value but never used
await commentPr(octokit, pr.number, todos)
}
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message)
Expand Down Expand Up @@ -154,7 +154,7 @@ export function findTodos(prDiff: PrDiff): Todo[] {
}

function getTodoIfFound(line: string): string | undefined {
const regex = /[/*#]+.*(TODO.*)/i
const regex = /[/*#]+.*(TODO.*|FIXME.*)/i
const matches = [...line.matchAll(regex)]
if (matches === undefined || matches.length === 0) return
return matches[0][1]
Expand All @@ -178,7 +178,7 @@ async function commentPr(
const removedTodos = todo.todos.filter(todo => !todo.added)

Check failure on line 178 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

'todo' is already declared in the upper scope on line 176 column 14

Check failure on line 178 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

'todo' is already declared in the upper scope on line 176 column 14

for (const innerTodo of addedTodos) {
let response = await octokit.rest.pulls.createReviewComment({
await octokit.rest.pulls.createReviewComment({
owner,
repo,
pull_number: prNumber,
Expand All @@ -191,7 +191,7 @@ async function commentPr(
}

for (const innerTodo of removedTodos) {
let response = await octokit.rest.pulls.createReviewComment({
await octokit.rest.pulls.createReviewComment({
owner,
repo,
pull_number: prNumber,
Expand Down

0 comments on commit 94e5de4

Please sign in to comment.