removing duplicate tags before sending. reduced number of tags for git and svn projects. recursively finding parent svn directory.

This commit is contained in:
Alan Hamlett 2013-07-20 14:42:19 -07:00
parent 9244c6b0b7
commit d1fc0ba0db
3 changed files with 31 additions and 19 deletions

View file

@ -124,7 +124,7 @@ def send_action(project=None, tags=None, key=None, targetFile=None,
if project: if project:
data['project'] = project data['project'] = project
if tags: if tags:
data['tags'] = tags data['tags'] = set(tags)
log.debug(data) log.debug(data)
request = urllib2.Request(url=url, data=json.dumps(data)) request = urllib2.Request(url=url, data=json.dumps(data))
user_agent = get_user_agent(plugin) user_agent = get_user_agent(plugin)

View file

@ -37,13 +37,14 @@ class Git(BaseProject):
def tags(self): def tags(self):
tags = [] tags = []
if self.config: if self.config:
base = self._project_base() proj_name = self.name()
if base: if proj_name:
tags.append(base) tags.append(proj_name)
sections = self._parse_config() sections = self._parse_config()
for section in sections: for section in sections:
if section.split(' ', 1)[0] == 'remote' and 'url' in sections[section]: if section.split(' ', 1)[0] == 'remote' and 'url' in sections[section]:
tags.append(sections[section]['url']) remote = sections[section]['url'].rsplit(':', 1)[1].rsplit('/', 1)[1].split('.git', 1)[0]
tags.append(remote)
branch = self._current_branch() branch = self._current_branch()
if branch is not None: if branch is not None:
tags.append(branch) tags.append(branch)

View file

@ -23,20 +23,23 @@ log = logging.getLogger(__name__)
class Subversion(BaseProject): class Subversion(BaseProject):
def process(self): def process(self):
self.info = self._get_info() return self._find_project_base(self.path)
if 'Repository Root' in self.info:
return True
return False
def name(self): def name(self):
return self.info['Repository Root'].split('/')[-1] return self.info['Repository Root'].split('/')[-1]
def _get_info(self): def tags(self):
tags = []
if self.base:
tags.append(os.path.basename(self.base))
return tags
def _get_info(self, path):
info = OrderedDict() info = OrderedDict()
stdout = None stdout = None
try: try:
stdout, stderr = Popen([ stdout, stderr = Popen([
'svn', 'info', os.path.realpath(self.path) 'svn', 'info', os.path.realpath(path)
], stdout=PIPE, stderr=PIPE).communicate() ], stdout=PIPE, stderr=PIPE).communicate()
except OSError: except OSError:
pass pass
@ -53,11 +56,19 @@ class Subversion(BaseProject):
info[line[0]] = line[1] info[line[0]] = line[1]
return info return info
def tags(self): def _find_project_base(self, path, found=False):
tags = [] path = os.path.realpath(path)
for key in self.info: if os.path.isfile(path):
if key == 'Repository UUID': path = os.path.split(path)[0]
tags.append(self.info[key]) info = self._get_info(path)
if key == 'URL': if len(info) > 0:
tags.append(os.path.dirname(self.info[key])) found = True
return tags self.base = path
self.info = info
elif found:
return True
split_path = os.path.split(path)
if split_path[1] == '':
return found
return self._find_project_base(split_path[0], found)