SidneyNemzer / snippets

A Chrome extension that allows you to create and edit JavaScript code snippets, which are synced to all your computers
https://chrome.google.com/webstore/detail/snippets/fakjeijchchmicjllnabpdkclfkpbiag
62 stars 9 forks source link

Add support of github enterprise #25

Open jianwu opened 3 years ago

jianwu commented 3 years ago

For many snippets that is work related. We can't store them in public github. So if this can store enterprise github will be great.

SidneyNemzer commented 3 years ago

Note that you can create a "secret" gist which is not listed publicly. However I think anyone can access it with the link, which understandably isn't acceptable for enterprise code.

I've never used GitHub enterprise but I assume it provides separate Gist storage? If so, we'd just need to replace github.com in a few places with a configurable hostname.

Looks like these URLs need to use the configurable hostname:

https://github.com/SidneyNemzer/snippets/blob/a5cab283057ab61058d4b6f2136f4b88f85c423f/src/editor/constants.js#L9-L13

https://github.com/SidneyNemzer/snippets/blob/a5cab283057ab61058d4b6f2136f4b88f85c423f/src/editor/components/SelectGist.js#L10

And then set the baseUrl for octokit: https://github.com/octokit/core.js#options

This would need to be another item in the settings page, and probably available as an option on the Login page too, hidden behind a button that says "Using GitHub Enterprise?".

I don't have time to dedicate to snippets right now, but I would accept a PR if you or someone else has time to implement this. I also don't have access to a GitHub Enterprise server so I would need help testing the changes.