One interesting aspect of working at Mozilla is that Firefox lives in a mercurial repository while several other projects live on GitHub in a git repository. While most focus on either Firefox or another project, I switch between both, leaving me running git
commands inside the mercurial repository and hg
commands inside git repos. It’s a frustration that I’ve lived with for a while so I sought to find a unified way of completing common tasks.
The first step was learning to detect git from command line:
if git rev-parse --git-dir > /dev/null 2>&1; then # git repo! else # NOT a git repo! fi
The if
statement above detects a git repository, the else
means the current directory is not inside a git repo.
One frequent task is checking out master and pulling the latest code from upstream, so I create an alias to do just that:
master() { if git rev-parse --git-dir > /dev/null 2>&1; then git checkout master && git pull upstream master else hg pull && hg checkout "last(public())" fi }
This alias will save me time and frustration moving forward, and I’m sure I’ll find other aliases to create based on git detection!
Send Text Messages with PHP
Kids these days, I tell ya. All they care about is the technology. The video games. The bottled water. Oh, and the texting, always the texting. Back in my day, all we had was…OK, I had all of these things too. But I still don’t get…
Create a Context Menu with Dojo and Dijit
Context menus, used in the right type of web application, can be invaluable. They provide shortcut methods to different functionality within the application and, with just a right click, they are readily available. Dojo’s Dijit frameworks provides an easy way to create stylish, flexible context…