-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get entire repo comments on app install #66
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this approach of looking at last x number commits is not optimal can you see if you can get root directories in a repo by using content api
without passing in a file path.
PR title is not informative. PR title should be short description of issue you are working on and maybe issue number |
Remember when we have root directories of a repo, we can recursively get files in the entire project |
src/lib/github/utils.ts
Outdated
return Promise.all(modifiedFiles); | ||
} | ||
|
||
export async function getfileNames(octokit, owner, repo, sha) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing types
@@ -0,0 +1,15 @@ | |||
/** | |||
* Gets files that have changed in the last commits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe comment should change. I think it should be something like Get all repo files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach looks good, could you test this out on a repo and get back to me on how it works out .
this method octokit.gitdata.getTree({owner, repo, sha, recursive: 5}); we are only able to recursively get the fileName and fileContent but if we wanted to use our app to be able to push there are some necessary adjustments needed like getting author and htmlUrl |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment please address and ping me after.
src/lib/github/getFilesOnInstall.ts
Outdated
import { getBasicRepoProps, getfileNames } from "./utils"; | ||
|
||
export default async function getFiles(context: Context): Promise<ModifiedFile[]> { | ||
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}); | ||
return treeObject.tree.map( async (obj) => { | ||
const arrFile: File[] = treeObject.tree.map( async (obj) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arrFile
type is wrong. It returns an array of Promises, so its type is rightly
const arrFile: Array<Promise<File[]>>
To make it File[]
you will have to use Promise.all and await
on the returned values of treeObject.tree.map function
@aleku399 I tried running the app in this branch and discovered a number of issues to work on; 1 - we should listen to 2 - The data returned from the installation repository events is of a different type from the one we have worked with before. see https://developer.github.com/v3/activity/events/types/#installationrepositoriesevent. This means you may need to write a new function for getting repository properties something like 3 - Since the installation doesn't have a 4 - I think you should eventually break up the function in |
No description provided.