From c3642fade2338e9295e6837389a661fc9fe7778c Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Fri, 13 Dec 2013 16:33:09 +0100 Subject: [PATCH] second line in .wakatime-project sets branch name --- wakatime/projects/wakatime.py | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/wakatime/projects/wakatime.py b/wakatime/projects/wakatime.py index c558467..db9ed56 100644 --- a/wakatime/projects/wakatime.py +++ b/wakatime/projects/wakatime.py @@ -4,7 +4,8 @@ ~~~~~~~~~~~~~~~~~~~~~~~~~~ Information from a .wakatime-project file about the project for - a given file. + a given file. First line of .wakatime-project sets the project + name. Second line sets the current branch name. :copyright: (c) 2013 Alan Hamlett. :license: BSD, see LICENSE for more details. @@ -23,20 +24,26 @@ class WakaTime(BaseProject): def process(self): self.config = self._find_config(self.path) + self._project_name = None + self._project_branch = None + if self.config: + + try: + with open(self.config) as fh: + self._project_name = unicode(fh.readline().strip()) + self._project_branch = unicode(fh.readline().strip()) + except IOError as e: + log.exception("Exception:") + return True return False def name(self): - try: - with open(self.config) as fh: - return unicode(fh.readline().strip()) - except IOError as e: - log.exception("Exception:") - return None + return self._project_name def branch(self): - return None + return self._project_branch def _find_config(self, path): path = os.path.realpath(path)