salimfadhley/jenkinsapi — pull request #131 by sudharsh (2013-06-25 13:40:32+00:00)
Title: Fix Build.get_revision() for git repositories

With Jenkins, 1.5xx `Build.get_revision` is failing with the following error,

```
In [26]: b.get_revision()
---------------------------------------------------------------------------
AttributeError
Traceback (most recent call last)
in ()
----> 1 b.get_revision()

/Users/sudharsh/venv/foobar/lib/python2.7/site-packages/jenkinsapi/build.pyc in get_revision(self)
45 def get_revision(self):
46 vcs = self._data['changeSet']['kind'] or 'git'
---> 47 return getattr(self, '_get_%s_rev' % vcs, lambda: None)()
48
49 def _get_svn_rev(self):

/Users/sudharsh/venv/foobar/lib/python2.7/site-packages/jenkinsapi/build.pyc in _get_git_rev(self)
55 def _get_git_rev(self):
56 for item in self._data['actions']:
---> 57 branch = item.get('buildsByBranchName')
58 head = branch and branch.get('origin/HEAD')
59 if head:

AttributeError: 'NoneType' object has no attribute 'get'
-----
```

This was because the `branch` was `origin/master` instead of `origin/HEAD`.

The attached patch removes this dependance and will work on any remote