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 e25f5ac
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
24 changes: 12 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29081,15 +29081,15 @@ function run() {
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 todos = findTodos(prDiff)
// console.log('Todos:', JSON.stringify(todos))
// const useOutput = core.getInput('use-output')
// await 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 = 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);
}
catch (error) {
if (error instanceof Error) {
Expand Down Expand Up @@ -29154,7 +29154,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 +29173,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 +29185,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.

24 changes: 12 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,17 @@ export async function run(): Promise<void> {
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 89 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 89 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 e25f5ac

Please sign in to comment.