From e48c1483345264844d1af7f8dda7559256aa572c Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Sun, 13 Oct 2013 16:44:11 -0700 Subject: [PATCH] upgrade wakatime plugin to v0.4.8 --- plugin/packages/wakatime/HISTORY.rst | 12 ++++++++ plugin/packages/wakatime/wakatime/__init__.py | 2 +- .../wakatime/wakatime/projects/git.py | 28 +++++++------------ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/plugin/packages/wakatime/HISTORY.rst b/plugin/packages/wakatime/HISTORY.rst index e5bc2cb..94d15c3 100644 --- a/plugin/packages/wakatime/HISTORY.rst +++ b/plugin/packages/wakatime/HISTORY.rst @@ -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) ++++++++++++++++++ diff --git a/plugin/packages/wakatime/wakatime/__init__.py b/plugin/packages/wakatime/wakatime/__init__.py index 09635cd..2321a31 100644 --- a/plugin/packages/wakatime/wakatime/__init__.py +++ b/plugin/packages/wakatime/wakatime/__init__.py @@ -12,7 +12,7 @@ from __future__ import print_function __title__ = 'wakatime' -__version__ = '0.4.7' +__version__ = '0.4.8' __author__ = 'Alan Hamlett' __license__ = 'BSD' __copyright__ = 'Copyright 2013 Alan Hamlett' diff --git a/plugin/packages/wakatime/wakatime/projects/git.py b/plugin/packages/wakatime/wakatime/projects/git.py index 94f1cc2..ef19a89 100644 --- a/plugin/packages/wakatime/wakatime/projects/git.py +++ b/plugin/packages/wakatime/wakatime/projects/git.py @@ -11,7 +11,6 @@ import logging import os -from subprocess import Popen, PIPE from .base import BaseProject try: @@ -38,23 +37,16 @@ class Git(BaseProject): return None def branch(self): - stdout = None - try: - stdout, stderr = Popen([ - 'git', 'branch', '--no-color' - ], stdout=PIPE, stderr=PIPE, cwd=self._project_base() - ).communicate() - except OSError: - pass - if stdout: - 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 - + branch = None + base = self._project_base() + if base: + head = os.path.join(self._project_base(), '.git', 'HEAD') + try: + with open(head) as f: + branch = f.readline().strip().rsplit('/', 1)[-1] + except IOError: + pass + return branch def _project_base(self): if self.config: