Blaming in Zend Studio

      No Comments on Blaming in Zend Studio

Very often when debugging issues I stumble upon a problematic line of code and ask myself “Who added this? When? What purpose for?”. If the source code is maintained in a Git repository then there is a designated Git command – blame – that can greatly help answering these questions.

Zend Studio, with the help of the EGit plugin, provides a very handy integration of the git-blame command directly in the code editor. To enable blaming, right-click inside the editor and choose Team > Show Annotations from the context menu. This will add some colorful markers next to the editor’s left margin where the line numbers appear.

The annotation markers can be expanded in size by right-clicking on any of them and using the available options under the Revisions submenu. Selecting “Show Author” and “Show Id” will display this information directly in the annotation. I find the “Combined Coloring” option useful too.

git-blame-1

Hovering on the annotation next to the line of interest will show a popup window with details of the last commit that modified this line. It shows important info like date, author, commit description and code diff. If more details are required, there are handy navigation links to the Commit viewer and the History view.

git-blame-2

When the blame annotations are not needed anymore, they can be hidden by choosing Revisions > Hide Revision Information from the annotation’s context menu.