GitHub Cloning Plugin

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:
blob.png

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:
blob.png

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.

13 Likes

Whatever happened to that new place file structure that they demoed at RDC last year? It saved and loaded scripts and stuff locally in directories easily usable for git.

Anyways, this is real neato, I’ll definitely be using it. Great job!

5 Likes

Also interested

On-topic:
Will definitely be using this

Hey @zeuxcg,

Do you have any information regarding this feature ? It seems that a lot of programmers on the ROBLOX platform are using Github for there projects, and it would be lovely to have built-in support for ROBLOX :slight_smile:

Thanks !

@OP
You are literally the best :slight_smile: I use your Sublime tools daily, really nice resource for any ROBLOX programmer !

This plugin is awesome and I can’t thank you enough for it. We’re one step closer to a proper development environment and I can’t wait to start using this!

I would like to ask if you would be able to look into private repositories as it would be an absolute requirement for using this in production. Not necessarily a fancy UI implementation for user authentication, I wouldn’t mind building the plugin from source or using my own web server for security.

Would be amazing if we can commit from ROBLOX back to Github :slight_smile: (I know this is quite hard with the limits in place, but would be a really neat feature !)

Good to hear this is useful; thanks for the feedback! I have ideas that might make dealing with non-script assets easier, too - keep an eye out for those.

Sure thing! I’ll probably implement this via API tokens, so I don’t have to handle sending passwords/handling 2FA/etc. You’d create the token manually, then give it to the plugin in order for it to access private repositories that the account associated with the token has access to.

It would be, but it’s quite difficult. No promises, and even if it does happen it won’t be for a while. The plugin right now has no interaction with Git proper; committing back would require a pure Lua implementation of Git. Further, the GitHub API is not particularly optimized for low request count; committing a large amount of changes could take several minutes due to exceeding either the plugin’s internal request limit or the HttpService global limit.

2 Likes

Update: version 1.1.0 is live!

The two main features are the ability to input an API key to access private repositories (cc @Wsly) and the ability to specify the default instance class, for repositories like the wiki libraries or Nevermore that don’t have type hints. To allow you to force files to be scripts, there are three shorthands, used in the same way as the ones for ModuleScripts and LocalScripts:

  • scr
  • server
  • script

Since you can’t see personal API keys after you generate them, the plugin will save the one you most recently used. The key is saved after it is successfully used to clone a repository, so an invalid key won’t overwrite any valid key you have saved.

2 Likes

yes my guy said it. thanks for bringing it up.

that would be really nice but something i always wanted “A plugin or a Roblox Feature that push or commit changes to the github repository”. That would be awesome especially if you want to save the code for a future use