removing duplicate tags before sending. reduced number of tags for git and svn projects. recursively finding parent svn directory.
This commit is contained in:
parent
9244c6b0b7
commit
d1fc0ba0db
3 changed files with 31 additions and 19 deletions
|
@ -124,7 +124,7 @@ def send_action(project=None, tags=None, key=None, targetFile=None,
|
|||
if project:
|
||||
data['project'] = project
|
||||
if tags:
|
||||
data['tags'] = tags
|
||||
data['tags'] = set(tags)
|
||||
log.debug(data)
|
||||
request = urllib2.Request(url=url, data=json.dumps(data))
|
||||
user_agent = get_user_agent(plugin)
|
||||
|
|
|
@ -37,13 +37,14 @@ class Git(BaseProject):
|
|||
def tags(self):
|
||||
tags = []
|
||||
if self.config:
|
||||
base = self._project_base()
|
||||
if base:
|
||||
tags.append(base)
|
||||
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]:
|
||||
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()
|
||||
if branch is not None:
|
||||
tags.append(branch)
|
||||
|
|
|
@ -23,20 +23,23 @@ log = logging.getLogger(__name__)
|
|||
class Subversion(BaseProject):
|
||||
|
||||
def process(self):
|
||||
self.info = self._get_info()
|
||||
if 'Repository Root' in self.info:
|
||||
return True
|
||||
return False
|
||||
return self._find_project_base(self.path)
|
||||
|
||||
def name(self):
|
||||
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()
|
||||
stdout = None
|
||||
try:
|
||||
stdout, stderr = Popen([
|
||||
'svn', 'info', os.path.realpath(self.path)
|
||||
'svn', 'info', os.path.realpath(path)
|
||||
], stdout=PIPE, stderr=PIPE).communicate()
|
||||
except OSError:
|
||||
pass
|
||||
|
@ -53,11 +56,19 @@ class Subversion(BaseProject):
|
|||
info[line[0]] = line[1]
|
||||
return info
|
||||
|
||||
def tags(self):
|
||||
tags = []
|
||||
for key in self.info:
|
||||
if key == 'Repository UUID':
|
||||
tags.append(self.info[key])
|
||||
if key == 'URL':
|
||||
tags.append(os.path.dirname(self.info[key]))
|
||||
return tags
|
||||
def _find_project_base(self, path, found=False):
|
||||
path = os.path.realpath(path)
|
||||
if os.path.isfile(path):
|
||||
path = os.path.split(path)[0]
|
||||
info = self._get_info(path)
|
||||
if len(info) > 0:
|
||||
found = True
|
||||
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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue