git_cache = os.path.join(os.getenv('GIT_CACHE_DIR'))
if event_fields.get('github'):
github = event_fields.get('github')
- for item in github:
- for p in item:
- if prj == p:
- giturl = item[p]
- 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)
- print 'org=%s git_full_name = %s' %(gitorg, git_full_name)
- break
+ if github.get(prj):
+ giturl = github.get(prj)
+ 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)
+ print 'org=%s git_full_name = %s' %(gitorg, git_full_name)
+ else:
+ print 'project: %s is not present in github'%(prj)
else: # GERRIT
prjdir = os.path.join(git_cache, prj)
giturl = None
return data
-def request_github_accepted(data, targetpackagelist=[]):
+def request_github_accepted(data, gitprj, targetpackagelist=[]):
"""Do lots of things when request accepted"""
print '====request accepted===================================='
data["GIT_TAG"],
request_url(data['OBS_REQ_ID']))
+ obs_target = data['OBS_REQ_PRJ'].lower().replace(':', '/')
+ timestamp = datetime.datetime.utcnow().strftime("%Y%m%d.%H%M%S")
+
+ # use os.path.join() to avoid '//', which is invalid as tag name
+ accepted_tag = os.path.join('accepted', obs_target, timestamp)
+
+ gitprj.create_tag(accepted_tag, message, data['commitid'])
+ sleep(1)
+
+ remote = '%s/%s' % (data['GITHUB_URL'], data['GIT_PROJECT'])
+ try:
+ gitprj.push_tag(remote, accepted_tag)
+ except GitRepositoryError, gre:
+ print gre
+ return 1
+
+ # push accepted commit to accepted branch refs/heads/accepted/*
+ # e.g. changes, accepted for Tizen:Mobile should be pushed to
+ # branch refs/heads/accepted/tizen_mobile
+ dst = 'refs/heads/accepted/%s' % \
+ data['OBS_REQ_PRJ'].lower().replace(':', '_')
+ try:
+ gitprj.push(remote, data['commitid'], dst, force=True)
+ except GitRepositoryError, gre:
+ print gre
+ return 1
+
+
additional_comment = REPAIR_COMMENT \
% (data['OBS_REQ_ID'], os.getenv('OBS_URL_EXTERNAL'), data['OBS_REQ_ID'], \
data['OBS_REQ_DESP'])
for project_data in projects_data:
data.update(project_data)
+ git_cache = os.path.join(os.getenv('GIT_CACHE_DIR'))
+ if event_fields.get('github'):
+ github = event_fields.get('github')
+ if github.get(data['GIT_PROJECT']):
+ giturl = event_fields.get('github').get(data['GIT_PROJECT'])
+ gitorg = giturl.split(':')[1]
+ git_full_name = os.path.join(gitorg, data['GIT_PROJECT'])
+ data['GITHUB_URL'] = giturl
+ prjdir = os.path.join(git_cache, git_full_name)
+ git_cache_dir = os.path.join(git_cache, gitorg)
+ print 'org=%s git_full_name = %s' %(gitorg, git_full_name)
+ else:
+ print 'project: %s is not present in github'%(prj)
+ else:
+ prjdir = os.path.join(git_cache, data['GIT_PROJECT'])
+ giturl = None
+ git_cache_dir = None
+
+ try:
+ gitprj = Git(prjdir)
+ except GitRepositoryError, err:
+ # clone project to local workspace if it doesn't exist in git cache
+ print "clone"
+ 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']))
+
if event_type == 'OBS_SRCSRV_REQUEST_STATECHANGE':
if event_fields['state'] == 'declined':
request_github_rejected(data)
elif event_fields['state'] == 'revoked':
request_github_revoked(data)
elif event_fields['state'] == 'accepted':
- request_github_accepted(data, reqinfo.get('targetpackagelist', None))
+ request_github_accepted(data, gitprj, reqinfo.get('targetpackagelist', None))
return data
saved_info = build.get_info(event_fields['sourceproject'])
event_fields['packages'] = \
unicode_to_str(saved_info['packages'])
+
# SR-SYNC: SR listing and its pure git repos.
if 'submissions' in saved_info:
submissions = unicode_to_str(saved_info['submissions'])