diff --git a/src/get-changed-files.ts b/src/get-changed-files.ts index b9420eb..1aea846 100644 --- a/src/get-changed-files.ts +++ b/src/get-changed-files.ts @@ -1,7 +1,7 @@ import { exec } from 'child_process'; export const getChangedFiles = async (base: string, head: string) => { - const command = `git diff --name-only ${base} ${head}`; + const command = `git diff --name-only ${base.trim()} ${head.trim()}`; console.log({ command, base, head }); return new Promise((resolve, reject) => { exec(command.trim(), (error, stdout) => { diff --git a/src/index.ts b/src/index.ts index ac39441..9caba0b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,7 @@ -import { context } from '@actions/github'; -// import { getChangedFiles } from './get-changed-files'; -// import { getReviewersUsernames } from './changed-files-reviewers'; -// import { getInput } from '@actions/core'; -import { exec } from 'child_process'; +import { context, getOctokit } from '@actions/github'; +import { getChangedFiles } from './get-changed-files'; +import { getReviewersUsernames } from './changed-files-reviewers'; +import { getInput } from '@actions/core'; /** * STEPS @@ -23,24 +22,24 @@ import { exec } from 'child_process'; const run = async () => { try { console.log({ pr: context.payload.pull_request }); - // const baseSha = - // context.payload.pull_request?.base.sha || - // '2d2f73c099310be56ace9e4aa3a922eb23ff0650'; - // const headSha = - // context.payload.pull_request?.head.sha || - // '71c867b0d68417a9de4774aedb92182169028538'; + const baseSha = + context.payload.pull_request?.base.sha || + '2d2f73c099310be56ace9e4aa3a922eb23ff0650'; + const headSha = + context.payload.pull_request?.head.sha || + '71c867b0d68417a9de4774aedb92182169028538'; - // const token = getInput('github-token'); - // const Octokit = getOctokit(token); + const token = getInput('github-token'); + const Octokit = getOctokit(token); - // const changedFiles = await getChangedFiles(baseSha, headSha); - // const usernames = await getReviewersUsernames(Octokit, changedFiles); + const changedFiles = await getChangedFiles(baseSha, headSha); + const usernames = await getReviewersUsernames(Octokit, changedFiles); - // console.log({ usernames, changedFiles }); + console.log({ usernames, changedFiles }); - exec('ls', (error, stdout) => { - console.log({ error, stdout }); - }); + // exec('ls', (error, stdout) => { + // console.log({ error, stdout }); + // }); } catch (error) { console.log({ error }); }