submitter = saved_info.get('submitter') or ''
download_num = saved_info.get('download_num') or int(0)
submissions = saved_info.get('submissions') or []
+ github = saved_info.get('github') or []
saved_info.update(info)
if 'projects' in info:
saved_info['projects'] = list(set(projects + info['projects']))
for s in info['submissions']:
submissions = filter(lambda a: a != s, submissions)
saved_info['submissions'] = submissions + info['submissions']
+ if 'github' in info:
+ for s in info['github']:
+ github = filter(lambda a: a != s, github)
+ saved_info['github'] = github + info['github']
self.set_description(json.dumps(saved_info), prj, pkg)
def get_info(self, prj, pkg=None):
"""Get info dictionary, saved in description."""
+
for count in (1, 2, 3):
description = self.get_description(prj, pkg)
if not description: continue
else:
return '%s' % (request_id)
-def tag_info(prj, tag):
+def tag_info(prj, tag, event_fields=None):
"""Get git tag info"""
+ git_cache = os.path.join(os.getenv('GIT_CACHE_DIR'))
+
+ if event_fields.get('github'):
+ github = event_fields.get('github')
+ prjdir = os.path.join(git_cache, prj)
+ giturl = None
+ git_cache_dir = None
+ for item in github:
+ if prj in item.get('project'):
+ giturl = github.get('url')
+ gitorg = giturl.split(':')[1]
+ git_full_name = os.path.join(gitorg, prj)
+ prjdir = os.path.join(git_cache, git_full_name)
+ git_cache_dir = os.path.join(git_cache, gitorg)
+ break
+ else: # GERRIT
+ prjdir = os.path.join(git_cache, prj)
+ giturl = None
+ git_cache_dir = None
+
try:
- mygit = Git('%s.git' % os.path.join(os.getenv('GIT_CACHE_DIR'), prj))
+ mygit = Git(prjdir)
if mygit.find_tag(tag):
return mygit.get_tag(tag)
except GitRepositoryError:
# tag is not found, try to clone
# clone gerrit project to local dir
- if not clone_gitproject(prj, os.path.join(os.getenv('WORKSPACE'), prj)):
+ if not clone_gitproject(prj, os.path.join(os.getenv('WORKSPACE'), prj), \
+ giturl=giturl, git_cache_dir=git_cache_dir):
exit(1)
mygit = Git(os.path.join(os.getenv('WORKSPACE'), prj))
obs_req_pkg_name = event_fields['packages'][projects.index(project)]
except Exception as err:
print 'Warning: not able to find package name from description'
- tag = tag_info(project, entry['GIT_TAG'])
+ tag = tag_info(project, entry['GIT_TAG'], event_fields)
if tag:
tag.update({'GIT_PROJECT': project,
'OBS_REQ_PKG_SRC': obs_req_pkg_name,
# SR-SYNC: SR listing and its pure git repos.
if 'submissions' in saved_info:
submissions = unicode_to_str(saved_info['submissions'])
+ if 'github' in saved_info:
+ event_fields['github'] = saved_info.get('github')
+
except Exception as err:
print 'Not able to fetch package list from OBS %s' % err
event_fields['packages'] = []
event_fields['state'] == 'revoked')):
notify_submiter(event_fields, data)
+ git_cache = os.path.join(os.getenv('GIT_CACHE_DIR'))
+ # Enable Github Connection
+ if event_fields.get('github'):
+ github = event_fields.get('github')
+ prjdir = os.path.join(git_cache, data['GIT_PROJECT'])
+ giturl = None
+ git_cache_dir = None
+ for item in github:
+ if data['GIT_PROJECT'] in item.get('project'):
+ giturl = item.get('url')
+ gitorg = giturl.split(':')[1]
+ git_full_name = os.path.join(gitorg, data['GIT_PROJECT'])
+ prjdir = os.path.join(git_cache, git_full_name)
+ git_cache_dir = os.path.join(git_cache, gitorg)
+ print "GITHUB prjdir=%s git_cache_dir=%s" %(prjdir, git_cache_dir)
+ break
+ else: # GERRIT
+ prjdir = os.path.join(git_cache, data['GIT_PROJECT'])
+ giturl = None
+ git_cache_dir = None
+ print "GERRIT prjdir=%s git_cache_dir=%s" %(prjdir, git_cache_dir)
try:
- gitprj = Git('%s/%s.git' % (os.getenv('GIT_CACHE_DIR'),
- data['GIT_PROJECT']))
+ gitprj = Git(prjdir)
except GitRepositoryError, err:
# clone project to local workspace if it doesn't exist in git cache
- if not clone_gitproject(data['GIT_PROJECT'],
- os.path.join(os.getenv('WORKSPACE'),
- data['GIT_PROJECT'])):
+ if not clone_gitproject(data['GIT_PROJECT'], \
+ os.path.join(os.getenv('WORKSPACE'), data['GIT_PROJECT']), \
+ giturl=giturl, git_cache_dir=git_cache_dir):
return -1
gitprj = Git('%s/%s' % (os.getenv('WORKSPACE'),
data['GIT_PROJECT']))