Git Hooks and Debug Software

If you’re doing any kind of UI work on iOS, I recommend you look into Reveal. You might think that the new Xcode 6 visual inspector solves all the problems Reveal proposes to solve, but it doesn’t. It complements it very nicely, by being able to do visual inspection on breakpoints, but for live manipulation and a more detailed analysis, I find Reveal essential.

But this is not a post about Reveal, this is a post about dealing with debug software annoyances. For instance, with Python and Ruby, there’s no way to do real breakpoints, instead we use some tools to hook into the code and provide a prompt at runtime, for instance Python’s pdb.trace(). So far so good, except when you accidentally forget to remove those lines and they get pushed upstream. Same goes for the Reveal linked framework. With multiple developers on the same project, you can easily get into a situation where the app won’t build because it can’t find a symlink’d framework.

Git hooks to the rescue. If you don’t know what git hooks are, I suggest you get yourself acquainted. Take a look at the samples inside your project’s .git/hooks folder. You can use any sort of scripting language, from bash to perl, to do all sort of tricks. From running automated tests to removing pdb.trace() lines to linked frameworks to whatever you can think of.

Today, after committing debug frameworks for the ${non-numerical vague quantifier} time, I got down and wrote a short pre-commit hook to remove it. If you use Reveal, this could be useful to you as well.

If you find any issues or improvements on my hook, please let me know.