-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat(providers/github): add GitHub provider #6
Conversation
provider: "github", | ||
type: this.docOnly | ||
? "document" // don't run iterating computation if we only retrieved documents anyways | ||
: isDoc(file.path) ? "document" : "code", |
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.
What's the schema for Document.type
? I know "document"
is valid, but is "code"
allowed?
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.
That's fine!
// 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("/") | ||
}`, |
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.
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.
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.
Sounds good, this should be fine.
Wow! This is awesome @mogery! This all looks really good. Thank you! |
// Decode the content blob as it is encoded | ||
const decodedContent = Buffer.from(blob.data.content, 'base64').toString('utf8'); | ||
|
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.
This may output large amounts of non-text data if binaries the repo contains binaries. Is that okay? Should we add UTF-8 detection?
/tip $20 |
Thank you! |
🎉🎈 @mogery has been awarded $20! 🎈🎊 |
Fixes #3
/claim #3
This PR adds a GitHub provider for retrieving files from public GitHub repositories, like described in #3.
Remarks: