Friday, February 22, 2013

Git Submodules: ICE ICE Beta

‹prev | My Chain | next›

I think that my recent changes in my fork of Mr Doob's code editor are ready for 3D Game Programming for Kids. Before I push these changes out there, I would like to make it available in a beta location as a trial.

The "ICE Code Editor" that is used throughout the book is actually just a GitHub pages site that resides at (currently the index page redirects to the Pragmatic landing page). Inside this gamingjs repository is a submodule that points to my fork of the code-editor:

I keep all of the ICE Code Editor changes that are specific to the book and in a branch, aptly named gamingjs. That is, I have a gamingjs GitHub pages repository and a matching gamingjs branch in the ICE Code Editor repository. All of which gives me a nice URL:

I believe that I can create a new submodule at /ice-beta, pointing to the latest commit in my code-editor. Instead of jumping right to the latest and greatest commit, however, I will temporarily point the /ice-beta submodule to the same commit currently used by /ice. This will give me a chance to verify the upgrade process.

I start by adding the submodule:
➜  gamingjs git:(gh-pages) ✗ git submodule add -b gamingjs ice-beta
Cloning into 'ice-beta'...
remote: Counting objects: 327, done.
remote: Compressing objects: 100% (139/139), done.
remote: Total 327 (delta 211), reused 297 (delta 185)
Receiving objects: 100% (327/327), 379.79 KiB | 157 KiB/s, done.
Resolving deltas: 100% (211/211), done.
Branch gamingjs set up to track remote branch gamingjs from origin.
That seems promising. By virtue of the -b option, this points to the gamingjs branch of code-editor (which is where I keep my changes). But it currently points to the latest commit in that branch:
➜  gamingjs git:(gh-pages) ✗ git submodule status ice
 bf110d41a15d25c6ce07defc775b5db439be12c6 ice (heads/gamingjs)
➜  gamingjs git:(gh-pages) ✗ git submodule status ice-beta
 4ef9699d7566a842b7fd677a16cc0ca7d88da057 ice-beta (heads/gamingjs)
That is ultimately where I want to go, but I switch back to the same commit used by /ice:
gamingjs git:(gh-pages) ✗ cd ice-beta
➜  ice-beta git:(gamingjs) git co bf110d41a15d25c6ce07defc775b5db439be12c6
Note: checking out 'bf110d41a15d25c6ce07defc775b5db439be12c6'.

# The usual detached HEAD note...

HEAD is now at bf110d4... Revert "Try to cache /ice (in addition to /ice/)"
I then change directory back into the gamingjs repository and commit the new submodule:
➜  ice-beta git:(bf110d4) cd ..
➜  gamingjs git:(gh-pages) ✗ git ci -m "Add /ice-beta path
dquote> Still pointing to the same SHA1 at /ice" -a

[gh-pages a3631f6] Add /ice-beta path
 2 files changed, 4 insertions(+)
 create mode 160000 ice-beta 
After pushing it to the GitHubs, I give the beta URL,, a try:

Perfect! It loads the code data from localStorage designated to the domain, which was all created by the original ICE Code Editor. But now I can try it out with the beta version of the code editor. Well, at least I will be able to once I update my submodule to point to the last commit instead of this old one.

So, back in my local git repository, I checkout the last commit on the gamingjs branch for the /ice-beta submodule:
➜  ice-beta git:(master) git co gamingjs 
Switched to branch 'gamingjs'
After checking the submodule's new SHA1 into the gamingjs repository and pushing the change, I load the /ice-beta URL one more time:

Yay! That is the application cache code borrowed from html5rocks. It does just what the confirmation dialog says: manages the new version process. I click OK and see all of the recent changes. Up tomorrow, I need to start a new project so that I can put the beta version through its paces.

Day #670

No comments:

Post a Comment