Wiki

Clone wiki

Core / AutoGist

AutoGist

Introduction

AutoGist is a Codea program that makes it easy to use version control via GitHub to keep track of changes in your projects, and to share projects with others. It is maintained by Briarfox based on original code by acp.

The AutoGist code lives in its own project in your Codea projects and should be imported in to each project that you want to use it with. In such a project then you add a couple of extra lines which AutoGist then uses to update the relevant gist on GitHub. Once it is installed, the top of a typical project will look something like:

VERSION = "1.5"
PROJECTNAME = "Name of your project"

function setup()
autoGist = AutoGist(PROJECTNAME,"An amazing project that needs version control",VERSION,[true|false])
autoGist:backup()
end

Then updating the gist simply involves updating the VERSION number.

Installation

Setting up AutoGist involves the following steps:

  1. Signing up for an account on GitHub. This will ask you to choose a username, to give an email address, and to choose a password. As with all such things, use a new password.

  2. Installing the AutoGist project. This is a simple process:

    1. Create a new project called AutoGist. Note the spelling and lack of spaces.
    2. Copy the code from this gist into the Main tab (completely replacing the automatically generated code).
    3. Run the project!
    4. Back out and run AutoGist. It will ask you for your GitHub username and password. It only needs these once and they are discarded afterwards. These are used to get a token which is used for future communication with GitHub. This token is stored in the global Codea data (which means that it is not exported with any particular project, including AutoGist).

Using AutoGist in a Project

Once AutoGist is setup, it can be used to create and update gists from your projects. There are a few options: you can bind a project to an existing gist, you can create a public or a private gist.

The difference between a public and a private gist is in discoverability. Public gists are listed on your GitHub user page. Private gists are not. However, if you share the link to a private gist then anyone with that link can download it (only you can ever upload to one of your gists). The public/private nature of a gist is set in stone when it is created and cannot be changed later.

New Private Gist

To create a new private gist from your project, do the following.

  1. Import the AutoGist project into your project. To do this, from the "tab" view click on the plus sign in the top right corner. From the dependency list click the AutoGist project.
  2. Add the following lines to your setup function, replacing the fields with the relevant data:
    autoGist = AutoGist("<ProjectName>","<Description>","<Version>")
    autoGist:backup()
    

Any of the information can be passed as a variable. In particular, it can be useful to have the "<Version>" in a global variable VERSION which is set at the very top of the Main tab. The point is that AutoGist will update the gist if the version is numerically bigger than the previous version so then updating is simply a matter of updating the VERSION number at the top of the code.

New Public Gist

To create a new public gist, do the same as for a new private gist except that the AutoGist.backup() line should be:

AutoGist:backup(true)

Create An Installer

  1. Gist your project.
  2. Go to the url and copy the last bit. This is your gistID
  3. Open AutoGist and select Create_Installer
  4. Enter your project Name and paste it's gist ID

This will create a new gist that you share. It's one file so it's easy to copy. Once ran, it will install the entire project.

Have your project check for updates

  1. Use autoGist = AutoGist(PROJECTNAME,"description",VERSION,true)
  2. When you change the version the update code will be added to Main.lua but will not clutter your project!
  3. If you have a project tab named ChangeLog, the updater will display it's contents on update.

Updated