From 969e5ba1bdd69883ebe0d7da775a7127e2a5de32 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Thu, 15 Aug 2013 00:14:26 -0700 Subject: [PATCH] upgraded wakatime package to v0.4.0 --- packages/wakatime/HISTORY.rst | 6 ++++ packages/wakatime/wakatime/__init__.py | 14 ++++----- packages/wakatime/wakatime/projects/base.py | 7 ++--- packages/wakatime/wakatime/projects/git.py | 30 +++++-------------- .../wakatime/wakatime/projects/mercurial.py | 4 +-- .../wakatime/wakatime/projects/subversion.py | 8 ++--- 6 files changed, 29 insertions(+), 40 deletions(-) diff --git a/packages/wakatime/HISTORY.rst b/packages/wakatime/HISTORY.rst index 5642693..f71aabe 100644 --- a/packages/wakatime/HISTORY.rst +++ b/packages/wakatime/HISTORY.rst @@ -2,6 +2,12 @@ History ------- +0.4.0 (2013-08-15) +++++++++++++++++++ + +- Sending single branch instead of multiple tags + + 0.3.1 (2013-08-08) ++++++++++++++++++ diff --git a/packages/wakatime/wakatime/__init__.py b/packages/wakatime/wakatime/__init__.py index 92e16f5..e5f7940 100644 --- a/packages/wakatime/wakatime/__init__.py +++ b/packages/wakatime/wakatime/__init__.py @@ -12,7 +12,7 @@ from __future__ import print_function __title__ = 'wakatime' -__version__ = '0.3.1' +__version__ = '0.4.0' __author__ = 'Alan Hamlett' __license__ = 'BSD' __copyright__ = 'Copyright 2013 Alan Hamlett' @@ -120,7 +120,7 @@ def get_user_agent(plugin): return user_agent -def send_action(project=None, tags=None, key=None, targetFile=None, +def send_action(project=None, branch=None, key=None, targetFile=None, timestamp=None, endtime=None, isWrite=None, plugin=None, **kwargs): url = 'https://www.wakati.me/api/v1/actions' log.debug('Sending action to api at %s' % url) @@ -134,8 +134,8 @@ def send_action(project=None, tags=None, key=None, targetFile=None, data['is_write'] = isWrite if project: data['project'] = project - if tags: - data['tags'] = list(set(tags)) + if branch: + data['branch'] = branch log.debug(data) # setup api request headers @@ -175,13 +175,13 @@ def main(argv=None): args = parseArguments(argv) setup_logging(args, __version__) if os.path.isfile(args.targetFile): - tags = [] + branch = None name = None project = find_project(args.targetFile) if project: - tags = project.tags() + branch = project.branch() name = project.name() - if send_action(project=name, tags=tags, **vars(args)): + if send_action(project=name, branch=branch, **vars(args)): return 0 return 102 else: diff --git a/packages/wakatime/wakatime/projects/base.py b/packages/wakatime/wakatime/projects/base.py index 728a7f8..8e1b7a5 100644 --- a/packages/wakatime/wakatime/projects/base.py +++ b/packages/wakatime/wakatime/projects/base.py @@ -47,8 +47,7 @@ class BaseProject(object): """ return None - def tags(self): - """ Returns an array of tag strings for the - path and/or project. + def branch(self): + """ Returns the current branch. """ - return [] + return None diff --git a/packages/wakatime/wakatime/projects/git.py b/packages/wakatime/wakatime/projects/git.py index 8a52dcb..94f1cc2 100644 --- a/packages/wakatime/wakatime/projects/git.py +++ b/packages/wakatime/wakatime/projects/git.py @@ -37,29 +37,7 @@ class Git(BaseProject): return os.path.basename(base) return None - def tags(self): - tags = [] - if self.config: - proj_name = self.name() - if proj_name: - tags.append(proj_name) - sections = self._parse_config() - for section in sections: - if section.split(' ', 1)[0] == 'remote' and 'url' in sections[section]: - remote = sections[section]['url'].rsplit(':', 1)[-1].rsplit('/', 1)[-1].split('.git', 1)[0] - if remote: - tags.append(remote) - branch = self._current_branch() - if branch is not None: - tags.append(branch) - return tags - - def _project_base(self): - if self.config: - return os.path.dirname(os.path.dirname(self.config)) - return None - - def _current_branch(self): + def branch(self): stdout = None try: stdout, stderr = Popen([ @@ -77,6 +55,12 @@ class Git(BaseProject): return line[1] return None + + def _project_base(self): + if self.config: + return os.path.dirname(os.path.dirname(self.config)) + return None + def _find_config(self, path): path = os.path.realpath(path) if os.path.isfile(path): diff --git a/packages/wakatime/wakatime/projects/mercurial.py b/packages/wakatime/wakatime/projects/mercurial.py index 7d9b2ae..4e9ce96 100644 --- a/packages/wakatime/wakatime/projects/mercurial.py +++ b/packages/wakatime/wakatime/projects/mercurial.py @@ -26,5 +26,5 @@ class Mercurial(BaseProject): def name(self): return None - def tags(self): - return [] + def branch(self): + return None diff --git a/packages/wakatime/wakatime/projects/subversion.py b/packages/wakatime/wakatime/projects/subversion.py index c8f54af..6a7aed5 100644 --- a/packages/wakatime/wakatime/projects/subversion.py +++ b/packages/wakatime/wakatime/projects/subversion.py @@ -31,11 +31,11 @@ class Subversion(BaseProject): def name(self): return self.info['Repository Root'].split('/')[-1] - def tags(self): - tags = [] + def branch(self): + branch = None if self.base: - tags.append(os.path.basename(self.base)) - return tags + branch = os.path.basename(self.base) + return branch def _get_info(self, path): info = OrderedDict()