If you’ve ever wanted to clone a GitHub repository straight into ROBLOX Studio, well…here you go. This is a simple(ish) plugin that will grab all .lua
and .rbxs
files out of a repository of your choice, optionally selecting a subfolder. It can even target branches and tags, for those of you that version your stuff.
Where to get it
You can download it from its place in the plugin library here. Alternatively you can get the plugin (or a zip of the source, if you’re so inclined) from the latest release on GitHub.
Usage
When you install the plugin there’ll be a button in the plugins tab: “Clone from GitHub”. Clicking it toggles this UI:
Paste in a repository URL (the clone button will gray out if the plugin can’t get what it needs [username and repository name] from the URL), enter a subfolder (optional), change the location if need be, and then press Clone. It’ll spit a bunch of stuff into the output (and some onscreen messages) and the files will be put into the clone location.
One quirk: You need to do some things to get it to create ModuleScripts and LocalScripts. There are two ways to do this:
- Naming the files
- Add a type comment (preferably near the top of the file)
You can see an example with both of these methods in the GitHub repository
The plugin has a set of shorthand names that map to ModuleScripts and LocalScripts:
{
loc = "LocalScript";
["local"] = "LocalScript";
mod = "ModuleScript";
module = "ModuleScript";
}
If a file is named in the form name.type.extension
, and type
is one of the entries in the table, the file’s contents will be put in an object of the corresponding class.
Alternatively, if you’d rather not rename your files, you can add a comment to them. It must look like this:
--# type=<some type>
To nest scripts inside other scripts, create a folder with the same name (without the extensions) in the same place as the file, then put your child scripts inside the folder. The example tree above shows this - it has a TestNested
module and a TestNested
folder, with two scripts in the folder. This produces the following structure in Studio:
Miscellaneous details
The plugin is open-source and can be found on GitHub here; please report issues there.
The plugin will self-limit to a maximum of 200 HTTP requests every 60 seconds. If it exceeds this limit, it will wait until enough outstanding requests (that it has made) expire to bring the number under 200. If it exceeds the global HttpService rate limit, it will sleep for 15 seconds before retrying the request. This process will continue until the request succeeds.
GitHub has a rate limit that they will enforce. For unauthenticated users (of which this plugin is), this is 60 requests. Each clone of a repository will result in one call to the GitHub API, so you can clone 60 repositories per hour with this. The plugin checks the rate limit for your IP before attempting to clone and will display a message if you have exceeded it (plus how many minutes before the limit resets).
There is a limit on how many files can be read from a tree at once with the GitHub API. This is, specifically, 1000 items. The plugin currently requests a recursive tree of all files from the root of the repository, so if your repository has more than 1000 files and folders in it, the plugin will not be able to clone all of them, even if you specify a subfolder. If this becomes an issue, I can fix it, but doing so would double the number of requests that have to be made against the GitHub API.
The plugin does not support authentication, so you cannot clone private repositories. The intended use of this is pulling open-source libraries down from GitHub that would be time consuming to do manually; let me know if you need to pull a private repository and I’ll look into it.