feat(providers/github): add GitHub provider#6
Merged
Conversation
mogery
commented
Jan 29, 2024
| provider: "github", | ||
| type: this.docOnly | ||
| ? "document" // don't run iterating computation if we only retrieved documents anyways | ||
| : isDoc(file.path) ? "document" : "code", |
Member
Author
There was a problem hiding this comment.
What's the schema for Document.type? I know "document" is valid, but is "code" allowed?
mogery
commented
Jan 29, 2024
Comment on lines
+186
to
+198
| // Construct pretty source URL. | ||
| sourceURL: `https://github.com/${ | ||
| encodeURIComponent(this.owner) | ||
| }/${ | ||
| encodeURIComponent(this.repo) | ||
| }/blob/${ | ||
| encodeURIComponent(branchName) | ||
| }/${ | ||
| file.path | ||
| .split("/") // Don't escape slashes, they're a part of the path. | ||
| .map(part => encodeURIComponent(part)) | ||
| .join("/") | ||
| }`, |
Member
Author
There was a problem hiding this comment.
This is pretty dodgy, but I couldn't find a better way to construct a URL. file.url points to an api.github.com link, which won't bring up the GitHub UI. This "pretty URL" does.
Member
There was a problem hiding this comment.
Sounds good, this should be fine.
Member
|
Wow! This is awesome @mogery! This all looks really good. Thank you! |
mogery
commented
Jan 29, 2024
Comment on lines
+175
to
+177
| // Decode the content blob as it is encoded | ||
| const decodedContent = Buffer.from(blob.data.content, 'base64').toString('utf8'); | ||
|
|
Member
Author
There was a problem hiding this comment.
This may output large amounts of non-text data if binaries the repo contains binaries. Is that okay? Should we add UTF-8 detection?
Member
|
/tip $20 |
Member
Author
|
Thank you! |
|
🎉🎈 @mogery has been awarded $20! 🎈🎊 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3
/claim #3
This PR adds a GitHub provider for retrieving files from public GitHub repositories, like described in #3.
Remarks: