using branch instead of tags

This commit is contained in:
Alan Hamlett 2013-08-15 00:09:27 -07:00
parent c410422c8a
commit 1aa88e4bf1
5 changed files with 22 additions and 39 deletions

View file

@ -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

View file

@ -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):

View file

@ -26,5 +26,5 @@ class Mercurial(BaseProject):
def name(self):
return None
def tags(self):
return []
def branch(self):
return None

View file

@ -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()