From 9575851065c1cfa2aa534dc8da4684a8a9eb3741 Mon Sep 17 00:00:00 2001 From: aleku399 Date: Fri, 2 Nov 2018 13:53:02 +0300 Subject: [PATCH 01/10] waiting for reviews #54 --- src/lib/github/getFilesOnInstall.ts | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/lib/github/getFilesOnInstall.ts diff --git a/src/lib/github/getFilesOnInstall.ts b/src/lib/github/getFilesOnInstall.ts new file mode 100644 index 0000000..c211e99 --- /dev/null +++ b/src/lib/github/getFilesOnInstall.ts @@ -0,0 +1,30 @@ +/** + * Gets files that have changed in the last commits + */ +import { Context } from "./types"; +import { getBasicRepoProps } from "./utils"; + +export interface ModifiedFile { + name: string; + downloadUrl: string; + htmlUrl: string; +} + +export default async function getFiles(context: Context): Promise { + const { owner, repo } = getBasicRepoProps (context); + const octokit = context.github; + const committedArray = await octokit.repos.getCommit({owner, repo}); + const changedFilesArray = committedArray.map( async (obj) => { + const sha = obj.sha; + return await octokit.repos.getCommit({owner, repo, sha}); + }); + // const arrayUniq = R.uniq(obj => obj.files[0].filename, changedFilesArray); + // wanted to remove duplicate files but realized files may have different todos + const modifiedFiles: Array> = + changedFilesArray.map(async(file) => { + const name = file.files[0].filename; + const content = await octokit.repos.getContent({owner, repo, path: name}); + return { name, htmlUrl: content.data.html_url, downloadUrl: content.data.download_url}; + }); + return Promise.all(modifiedFiles); +} From 77f753ef19061ab5459cd49740413be7398caf3d Mon Sep 17 00:00:00 2001 From: aleku399 Date: Mon, 5 Nov 2018 13:00:20 +0300 Subject: [PATCH 02/10] reviewed changes #54 --- src/lib/github/changedFilesList.ts | 10 ++-------- src/lib/github/getFilesOnInstall.ts | 16 ++++++---------- src/lib/github/utils.ts | 10 ++++++++++ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/lib/github/changedFilesList.ts b/src/lib/github/changedFilesList.ts index a494bcd..58ecaaa 100644 --- a/src/lib/github/changedFilesList.ts +++ b/src/lib/github/changedFilesList.ts @@ -2,7 +2,7 @@ * Gets files that have changed during a commit */ import { Context } from "./types"; -import { getBasicRepoProps } from "./utils"; +import { getBasicRepoProps, getModifiedFiles } from "./utils"; export interface ModifiedFile { name: string; @@ -20,11 +20,5 @@ export default async function getChangedFiles(context: Context): Promise> = - result.data.files.map(async(file) => { - const name = file.filename; - const content = await octokit.repos.getContent({owner, repo, path: name}); - return { name, htmlUrl: content.data.html_url, downloadUrl: content.data.download_url}; - }); - return Promise.all(modifiedFiles); + return getModifiedFiles(octokit, result, owner, repo); } diff --git a/src/lib/github/getFilesOnInstall.ts b/src/lib/github/getFilesOnInstall.ts index c211e99..45c345b 100644 --- a/src/lib/github/getFilesOnInstall.ts +++ b/src/lib/github/getFilesOnInstall.ts @@ -2,7 +2,7 @@ * Gets files that have changed in the last commits */ import { Context } from "./types"; -import { getBasicRepoProps } from "./utils"; +import { getBasicRepoProps, getModifiedFiles } from "./utils"; export interface ModifiedFile { name: string; @@ -13,18 +13,14 @@ export interface ModifiedFile { export default async function getFiles(context: Context): Promise { const { owner, repo } = getBasicRepoProps (context); const octokit = context.github; - const committedArray = await octokit.repos.getCommit({owner, repo}); + const committedArray = await octokit.repos.getCommits({owner, repo}); const changedFilesArray = committedArray.map( async (obj) => { const sha = obj.sha; return await octokit.repos.getCommit({owner, repo, sha}); }); - // const arrayUniq = R.uniq(obj => obj.files[0].filename, changedFilesArray); - // wanted to remove duplicate files but realized files may have different todos - const modifiedFiles: Array> = - changedFilesArray.map(async(file) => { - const name = file.files[0].filename; - const content = await octokit.repos.getContent({owner, repo, path: name}); - return { name, htmlUrl: content.data.html_url, downloadUrl: content.data.download_url}; + // not sure if we shall av a return type if we use map Promise + // we might return something like that + return changedFilesArray.forEach(async(file) => { + return getModifiedFiles(octokit, file, owner, repo); }); - return Promise.all(modifiedFiles); } diff --git a/src/lib/github/utils.ts b/src/lib/github/utils.ts index a5e4406..e055b77 100644 --- a/src/lib/github/utils.ts +++ b/src/lib/github/utils.ts @@ -5,6 +5,7 @@ import { groupBy, flatten, prop } from "ramda"; import { Context, Issue, RepoProps, GHIssue } from "./types"; import { RepoIssue } from "../parser"; +import { ModifiedFile } from "./getFilesOnInstall"; export function getBasicRepoProps (context: Context): RepoProps { @@ -44,3 +45,12 @@ export function mergeFileRepoIssues(repoIssues: RepoIssue[][]): RepoIssue[] { Object.keys(groupedByIssueType).map(key => groupedByIssueType[key]); return flatten(issueGroupsList); } + +export function getModifiedFiles(octokit, array, owner, repo): Promise { + const modifiedFiles: Array> = array.data.files.map(async(file) => { + const name = file.filename; + const content = await octokit.repos.getContent({owner, repo, path: name}); + return { name, htmlUrl: content.data.html_url, downloadUrl: content.data.download_url}; +}); + return Promise.all(modifiedFiles); +} From d462651ad15cfc7a8a71a8b91baeee6a6a84fd9b Mon Sep 17 00:00:00 2001 From: aleku399 Date: Wed, 7 Nov 2018 14:16:53 +0300 Subject: [PATCH 03/10] w.i.p --- src/lib/github/getFilesOnInstall.ts | 12 ++++++++---- src/lib/github/utils.ts | 12 ++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/lib/github/getFilesOnInstall.ts b/src/lib/github/getFilesOnInstall.ts index 45c345b..8aba87b 100644 --- a/src/lib/github/getFilesOnInstall.ts +++ b/src/lib/github/getFilesOnInstall.ts @@ -12,11 +12,15 @@ export interface ModifiedFile { export default async function getFiles(context: Context): Promise { const { owner, repo } = getBasicRepoProps (context); + const sha = context.payload.head_commit.id; const octokit = context.github; - const committedArray = await octokit.repos.getCommits({owner, repo}); - const changedFilesArray = committedArray.map( async (obj) => { - const sha = obj.sha; - return await octokit.repos.getCommit({owner, repo, sha}); + const treeObject = await octokit.gitdata.getTree({owner, repo, sha, recursive: 5}); + const changedFilesArray = treeObject.tree.map( async (obj) => { + if (obj.type !== "tree") { + return obj.path; + } else { + return await octokit.gitdata.getTree({owner, repo, sha: obj.sha}); + } }); // not sure if we shall av a return type if we use map Promise // we might return something like that diff --git a/src/lib/github/utils.ts b/src/lib/github/utils.ts index e055b77..d1b258e 100644 --- a/src/lib/github/utils.ts +++ b/src/lib/github/utils.ts @@ -54,3 +54,15 @@ export function getModifiedFiles(octokit, array, owner, repo): Promise { + if (obj.type !== "tree") { + return {path: obj.path, url: obj.url}; + } else { + return await getfileNames(octokit, owner, repo, obj.sha); + } + }); +} \ No newline at end of file From 4c74d3e729a9c14e95fd4688da065e1530a0c823 Mon Sep 17 00:00:00 2001 From: aleku399 Date: Mon, 12 Nov 2018 16:02:03 +0300 Subject: [PATCH 04/10] adding a recursive function to get files --- src/lib/github/getFilesOnInstall.ts | 24 +++++++----------------- src/lib/github/utils.ts | 2 +- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/src/lib/github/getFilesOnInstall.ts b/src/lib/github/getFilesOnInstall.ts index 8aba87b..62397fe 100644 --- a/src/lib/github/getFilesOnInstall.ts +++ b/src/lib/github/getFilesOnInstall.ts @@ -2,29 +2,19 @@ * Gets files that have changed in the last commits */ import { Context } from "./types"; -import { getBasicRepoProps, getModifiedFiles } from "./utils"; +import { getBasicRepoProps, getfileNames } from "./utils"; -export interface ModifiedFile { - name: string; - downloadUrl: string; - htmlUrl: string; +export interface File { + path: string; + url: string; } -export default async function getFiles(context: Context): Promise { +export default async function getFiles(context: Context): Promise { const { owner, repo } = getBasicRepoProps (context); const sha = context.payload.head_commit.id; const octokit = context.github; const treeObject = await octokit.gitdata.getTree({owner, repo, sha, recursive: 5}); - const changedFilesArray = treeObject.tree.map( async (obj) => { - if (obj.type !== "tree") { - return obj.path; - } else { - return await octokit.gitdata.getTree({owner, repo, sha: obj.sha}); - } + return treeObject.tree.map( async (obj) => { + return getfileNames(octokit, owner, repo, obj.sha); }); - // not sure if we shall av a return type if we use map Promise - // we might return something like that - return changedFilesArray.forEach(async(file) => { - return getModifiedFiles(octokit, file, owner, repo); - }); } diff --git a/src/lib/github/utils.ts b/src/lib/github/utils.ts index d1b258e..9c47eb4 100644 --- a/src/lib/github/utils.ts +++ b/src/lib/github/utils.ts @@ -5,7 +5,7 @@ import { groupBy, flatten, prop } from "ramda"; import { Context, Issue, RepoProps, GHIssue } from "./types"; import { RepoIssue } from "../parser"; -import { ModifiedFile } from "./getFilesOnInstall"; +import { ModifiedFile } from "./changedFilesList"; export function getBasicRepoProps (context: Context): RepoProps { From 66b2bbfd29fbfd1353be5840dddd6679a9b0654f Mon Sep 17 00:00:00 2001 From: aleku399 Date: Mon, 12 Nov 2018 20:31:37 +0300 Subject: [PATCH 05/10] refactoring some --- src/lib/github/changedFilesList.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/github/changedFilesList.ts b/src/lib/github/changedFilesList.ts index 0d90d74..a082ed1 100644 --- a/src/lib/github/changedFilesList.ts +++ b/src/lib/github/changedFilesList.ts @@ -2,7 +2,7 @@ * Gets files that have changed during a commit */ import { Context } from "./types"; -import { getBasicRepoProps, getModifiedFiles } from "./utils"; +import { getBasicRepoProps } from "./utils"; export interface ModifiedFile { name: string; From 6085f4104a257933240c7372b30a565ebefcfdd2 Mon Sep 17 00:00:00 2001 From: aleku399 Date: Tue, 13 Nov 2018 13:53:50 +0300 Subject: [PATCH 06/10] adding types --- src/lib/github/getFilesOnInstall.ts | 7 +------ src/lib/github/types.ts | 5 +++++ src/lib/github/utils.ts | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/github/getFilesOnInstall.ts b/src/lib/github/getFilesOnInstall.ts index 62397fe..61ad85b 100644 --- a/src/lib/github/getFilesOnInstall.ts +++ b/src/lib/github/getFilesOnInstall.ts @@ -1,14 +1,9 @@ /** * Gets files that have changed in the last commits */ -import { Context } from "./types"; +import { Context, File } from "./types"; import { getBasicRepoProps, getfileNames } from "./utils"; -export interface File { - path: string; - url: string; -} - export default async function getFiles(context: Context): Promise { const { owner, repo } = getBasicRepoProps (context); const sha = context.payload.head_commit.id; diff --git a/src/lib/github/types.ts b/src/lib/github/types.ts index 8173470..9ab94b7 100644 --- a/src/lib/github/types.ts +++ b/src/lib/github/types.ts @@ -22,3 +22,8 @@ export interface GHIssue { number: number; title: string; } + +export interface File { + path: string; + url: string; +} diff --git a/src/lib/github/utils.ts b/src/lib/github/utils.ts index 9c836da..19ff622 100644 --- a/src/lib/github/utils.ts +++ b/src/lib/github/utils.ts @@ -3,7 +3,7 @@ */ import { groupBy, flatten, prop } from "ramda"; -import { Context, Issue, RepoProps, GHIssue } from "./types"; +import { Context, Issue, RepoProps, GHIssue, File } from "./types"; import { RepoIssue } from "../parser"; import { ModifiedFile } from "./changedFilesList"; @@ -56,9 +56,9 @@ export function getModifiedFiles(octokit, array, owner, repo): Promise { const objFiles = await octokit.gitdata.getTree({owner, repo, sha}); - if (objFiles) return; + if (!objFiles) return; return objFiles.tree.map( async (obj) => { if (obj.type !== "tree") { return {path: obj.path, url: obj.url}; @@ -66,4 +66,4 @@ export async function getfileNames(octokit, owner, repo, sha) { return await getfileNames(octokit, owner, repo, obj.sha); } }); -} \ No newline at end of file +} From 781e4b03de2a5df87390fc7309b5b7355e991680 Mon Sep 17 00:00:00 2001 From: aleku399 Date: Thu, 6 Dec 2018 17:32:05 +0300 Subject: [PATCH 07/10] getting file names on install of the github app --- src/app/main.ts | 6 +++++- src/lib/github/changedFilesList.ts | 9 +-------- src/lib/github/getFilesOnInstall.ts | 4 ++-- src/lib/github/types.ts | 11 +++++++++-- src/lib/github/utils.ts | 8 +++----- src/lib/index.ts | 15 +++++++++++++++ 6 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/app/main.ts b/src/app/main.ts index b8d05fc..1bb3bb2 100644 --- a/src/app/main.ts +++ b/src/app/main.ts @@ -1,5 +1,5 @@ import { Context } from "../lib/github/types"; -import { addRepoCommentsToGH } from "../lib"; +import { addRepoCommentsToGH, addCommentsToGHonInstall } from "../lib"; module.exports = app => { app.log("Cheers, the app runs on a server!"); @@ -7,4 +7,8 @@ module.exports = app => { app.on("push", async (context: Context) => { addRepoCommentsToGH(context); }); + + app.on("installation", async (context: Context) => { + addCommentsToGHonInstall(context); + }); }; diff --git a/src/lib/github/changedFilesList.ts b/src/lib/github/changedFilesList.ts index a082ed1..99db5a1 100644 --- a/src/lib/github/changedFilesList.ts +++ b/src/lib/github/changedFilesList.ts @@ -1,16 +1,9 @@ /** * Gets files that have changed during a commit */ -import { Context } from "./types"; +import { Context, ModifiedFile } from "./types"; import { getBasicRepoProps } from "./utils"; -export interface ModifiedFile { - name: string; - downloadUrl: string; - htmlUrl: string; - author: string; -} - export default async function getChangedFiles(context: Context): Promise { const { owner, repo } = getBasicRepoProps (context); const sha = context.payload.head_commit.id; diff --git a/src/lib/github/getFilesOnInstall.ts b/src/lib/github/getFilesOnInstall.ts index 61ad85b..db4114e 100644 --- a/src/lib/github/getFilesOnInstall.ts +++ b/src/lib/github/getFilesOnInstall.ts @@ -1,10 +1,10 @@ /** * Gets files that have changed in the last commits */ -import { Context, File } from "./types"; +import { Context, ModifiedFile } from "./types"; import { getBasicRepoProps, getfileNames } from "./utils"; -export default async function getFiles(context: Context): Promise { +export default async function getFiles(context: Context): Promise { const { owner, repo } = getBasicRepoProps (context); const sha = context.payload.head_commit.id; const octokit = context.github; diff --git a/src/lib/github/types.ts b/src/lib/github/types.ts index 9ab94b7..8f6cb9e 100644 --- a/src/lib/github/types.ts +++ b/src/lib/github/types.ts @@ -23,7 +23,14 @@ export interface GHIssue { title: string; } +export interface ModifiedFile { + name: string; + downloadUrl: string; + htmlUrl: string; + author: string; +} + export interface File { - path: string; - url: string; + name: string; + downloadUrl: string; } diff --git a/src/lib/github/utils.ts b/src/lib/github/utils.ts index 19ff622..dfabf71 100644 --- a/src/lib/github/utils.ts +++ b/src/lib/github/utils.ts @@ -3,10 +3,8 @@ */ import { groupBy, flatten, prop } from "ramda"; -import { Context, Issue, RepoProps, GHIssue, File } from "./types"; +import { Context, Issue, RepoProps, GHIssue, ModifiedFile, File } from "./types"; import { RepoIssue } from "../parser"; -import { ModifiedFile } from "./changedFilesList"; - export function getBasicRepoProps (context: Context): RepoProps { const owner = context.payload.repository.owner.login; @@ -56,12 +54,12 @@ export function getModifiedFiles(octokit, array, owner, repo): Promise { +export async function getfileNames(octokit, owner: string, repo: string, sha: string): Promise { const objFiles = await octokit.gitdata.getTree({owner, repo, sha}); if (!objFiles) return; return objFiles.tree.map( async (obj) => { if (obj.type !== "tree") { - return {path: obj.path, url: obj.url}; + return {name: obj.path, downloadUrl: obj.url}; } else { return await getfileNames(octokit, owner, repo, obj.sha); } diff --git a/src/lib/index.ts b/src/lib/index.ts index b729e59..2078e17 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -7,6 +7,7 @@ import getChangedFiles from "../lib/github/changedFilesList"; import getFilesContent, { FilesContent } from "./github/getFilesContent"; import getNewIssuesFromSource from "./github/getNewIssue"; import addIssuesToRepo from "./github/addIssuesToRepo"; +import getFiles from "../lib/github/getFilesOnInstall"; import parseData from "./parser"; import { mergeFileRepoIssues } from "./github/utils"; @@ -26,3 +27,17 @@ export async function addRepoCommentsToGH(context: Context): Promise { return addIssuesToRepo(context, issuesToAddToRepo); } +export async function addCommentsToGHonInstall(context: Context): Promise { + // get changed files on a git push + const changedFiles = await getFiles(context); + // get file data + const filesContent: FilesContent[] = await getFilesContent(changedFiles); // error handling + // FIXME: this doesnot work + // Just ignore it + const filesRepoIssues = filesContent.map(parseData); + // merge into a single set of FIXME and TODO issues + const repoIssues = mergeFileRepoIssues(filesRepoIssues); + const issuesToAddToRepo = await getNewIssuesFromSource(context, repoIssues); + return addIssuesToRepo(context, issuesToAddToRepo); +} + From 98c187de6b17d099b51e014906293b6fc1b29e2f Mon Sep 17 00:00:00 2001 From: aleku399 Date: Thu, 6 Dec 2018 17:35:15 +0300 Subject: [PATCH 08/10] minor correction --- src/lib/github/getFilesContent.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/github/getFilesContent.ts b/src/lib/github/getFilesContent.ts index dc7a986..e296ee8 100644 --- a/src/lib/github/getFilesContent.ts +++ b/src/lib/github/getFilesContent.ts @@ -1,5 +1,5 @@ import fetch from "node-fetch"; -import { ModifiedFile } from "./changedFilesList"; +import { ModifiedFile } from "./types"; export interface FilesContent { content: string; From f63f96b5268dc61ddf93acb47e51478f660246e8 Mon Sep 17 00:00:00 2001 From: aleku399 Date: Sun, 9 Dec 2018 12:35:36 +0300 Subject: [PATCH 09/10] creating github issues on install --- src/lib/github/changedFilesList.ts | 6 +++--- src/lib/github/getFilesOnInstall.ts | 14 ++++++++++++-- src/lib/index.ts | 5 ++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/lib/github/changedFilesList.ts b/src/lib/github/changedFilesList.ts index 99db5a1..b80db8f 100644 --- a/src/lib/github/changedFilesList.ts +++ b/src/lib/github/changedFilesList.ts @@ -18,11 +18,11 @@ export default async function getChangedFiles(context: Context): Promise> = result.data.files.map(async(file) => { const name = file.filename; - const content = await octokit.repos.getContent({owner, repo, path: name}); + const content = await octokit.repos.getContents({owner, repo, path: name}); return { name, - htmlUrl: content.data.html_url, - downloadUrl: content.data.download_url, + htmlUrl: content.html_url, + downloadUrl: content.download_url, author }; }); diff --git a/src/lib/github/getFilesOnInstall.ts b/src/lib/github/getFilesOnInstall.ts index db4114e..704bfd2 100644 --- a/src/lib/github/getFilesOnInstall.ts +++ b/src/lib/github/getFilesOnInstall.ts @@ -1,7 +1,7 @@ /** * Gets files that have changed in the last commits */ -import { Context, ModifiedFile } from "./types"; +import { Context, ModifiedFile, File } from "./types"; import { getBasicRepoProps, getfileNames } from "./utils"; export default async function getFiles(context: Context): Promise { @@ -9,7 +9,17 @@ export default async function getFiles(context: Context): Promise { + const arrFile: File[] = treeObject.tree.map( async (obj) => { return getfileNames(octokit, owner, repo, obj.sha); }); + const modifiedFiles: Array> = arrFile.map( async (objFile: File) => { + const content = await octokit.repos.getContents({owner, repo, path: objFile.name}); + return { + name: objFile.name, + htmlUrl: content.html_url, + downloadUrl: content.download_url, + author: owner + }; + }); + return Promise.all(modifiedFiles); } diff --git a/src/lib/index.ts b/src/lib/index.ts index 2078e17..8a4a623 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -28,12 +28,11 @@ export async function addRepoCommentsToGH(context: Context): Promise { } export async function addCommentsToGHonInstall(context: Context): Promise { - // get changed files on a git push + // get changed files on install const changedFiles = await getFiles(context); // get file data const filesContent: FilesContent[] = await getFilesContent(changedFiles); // error handling - // FIXME: this doesnot work - // Just ignore it + const filesRepoIssues = filesContent.map(parseData); // merge into a single set of FIXME and TODO issues const repoIssues = mergeFileRepoIssues(filesRepoIssues); From 49e856efd3c2d9d5db587ec7c53f0a66033b370f Mon Sep 17 00:00:00 2001 From: aleku399 Date: Sun, 9 Dec 2018 18:38:02 +0300 Subject: [PATCH 10/10] correcting returned type for file Promises --- src/lib/github/getFilesOnInstall.ts | 7 ++++--- src/lib/github/utils.ts | 9 +++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/lib/github/getFilesOnInstall.ts b/src/lib/github/getFilesOnInstall.ts index 704bfd2..d6ac7bb 100644 --- a/src/lib/github/getFilesOnInstall.ts +++ b/src/lib/github/getFilesOnInstall.ts @@ -2,16 +2,17 @@ * Gets files that have changed in the last commits */ import { Context, ModifiedFile, File } from "./types"; -import { getBasicRepoProps, getfileNames } from "./utils"; +import { getBasicRepoProps, getfileName } from "./utils"; export default async function getFiles(context: Context): Promise { const { owner, repo } = getBasicRepoProps (context); const sha = context.payload.head_commit.id; const octokit = context.github; const treeObject = await octokit.gitdata.getTree({owner, repo, sha, recursive: 5}); - const arrFile: File[] = treeObject.tree.map( async (obj) => { - return getfileNames(octokit, owner, repo, obj.sha); + const filePromises: Array> = treeObject.tree.map( async (obj) => { + return getfileName(octokit, owner, repo, obj.sha); }); + const arrFile = await Promise.all(filePromises); const modifiedFiles: Array> = arrFile.map( async (objFile: File) => { const content = await octokit.repos.getContents({owner, repo, path: objFile.name}); return { diff --git a/src/lib/github/utils.ts b/src/lib/github/utils.ts index dfabf71..5ee4b72 100644 --- a/src/lib/github/utils.ts +++ b/src/lib/github/utils.ts @@ -54,14 +54,19 @@ export function getModifiedFiles(octokit, array, owner, repo): Promise { +export async function getfileName( + octokit, + owner: string, + repo: string, + sha: string +): Promise { const objFiles = await octokit.gitdata.getTree({owner, repo, sha}); if (!objFiles) return; return objFiles.tree.map( async (obj) => { if (obj.type !== "tree") { return {name: obj.path, downloadUrl: obj.url}; } else { - return await getfileNames(octokit, owner, repo, obj.sha); + return await getfileName(octokit, owner, repo, obj.sha); } }); }