upgrade wakatime plugin to v0.4.8

This commit is contained in:
Alan Hamlett 2013-10-13 16:44:11 -07:00
parent 6ba24c7214
commit e48c148334
3 changed files with 23 additions and 19 deletions

View file

@ -3,6 +3,18 @@ History
------- -------
0.4.8 (2013-10-13)
++++++++++++++++++
- Read git HEAD file to find current branch instead of running git command line
0.4.7 (2013-09-30)
++++++++++++++++++
- Sending local olson timezone string in api request
0.4.6 (2013-09-22) 0.4.6 (2013-09-22)
++++++++++++++++++ ++++++++++++++++++

View file

@ -12,7 +12,7 @@
from __future__ import print_function from __future__ import print_function
__title__ = 'wakatime' __title__ = 'wakatime'
__version__ = '0.4.7' __version__ = '0.4.8'
__author__ = 'Alan Hamlett' __author__ = 'Alan Hamlett'
__license__ = 'BSD' __license__ = 'BSD'
__copyright__ = 'Copyright 2013 Alan Hamlett' __copyright__ = 'Copyright 2013 Alan Hamlett'

View file

@ -11,7 +11,6 @@
import logging import logging
import os import os
from subprocess import Popen, PIPE
from .base import BaseProject from .base import BaseProject
try: try:
@ -38,23 +37,16 @@ class Git(BaseProject):
return None return None
def branch(self): def branch(self):
stdout = None branch = None
base = self._project_base()
if base:
head = os.path.join(self._project_base(), '.git', 'HEAD')
try: try:
stdout, stderr = Popen([ with open(head) as f:
'git', 'branch', '--no-color' branch = f.readline().strip().rsplit('/', 1)[-1]
], stdout=PIPE, stderr=PIPE, cwd=self._project_base() except IOError:
).communicate()
except OSError:
pass pass
if stdout: return branch
for line in stdout.splitlines():
if isinstance(line, bytes):
line = bytes.decode(line)
line = line.split(' ', 1)
if line[0] == '*':
return line[1]
return None
def _project_base(self): def _project_base(self):
if self.config: if self.config: