282 SR-Sync: Handle deleted git 92/146892/1
authorhyokeun <hyokeun.jeon@samsung.com>
Thu, 31 Aug 2017 04:48:12 +0000 (13:48 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Thu, 31 Aug 2017 04:48:12 +0000 (13:48 +0900)
Change-Id: Iafd8f42ca44a8b218eefee50f1748a2ca7f08221

job_submit_request_sync.py

index a97ddd2..2ed8126 100644 (file)
@@ -116,8 +116,8 @@ def main():
 
     print '---[JOB STARTED]-------------------------'
 
-    if os.getenv('SR_SYNC_ENABLED', '0') != '1':
-        return
+    #if os.getenv('SR_SYNC_ENABLED', '0') != '1':
+    #    return
 
     bm_start_datetime = datetime.now()
 
@@ -181,16 +181,16 @@ def main():
         branch = target['branch']
         source_branch = target['source_branch']
 
-        ret_data = {'project': official_data['project'],
-                    'project_to_create': official_data['project_to_create'],
-                    'requests': []}
-        if 'project_to_create' in ret_data and ret_data['project_to_create'] is not None:
-            project_to_create = ret_data['project_to_create']
-        else:
+        if True:
             project_to_create = 'home:prerelease:%s:submit:%s:%s' \
                                 % (target_project, \
                                    branch, \
                                    datetime.utcnow().strftime("%Y%m%d.%H%M%S"))
+
+        ret_data = {'project': official_data['project'],
+                    'project_to_create': project_to_create,
+                    'requests': []}
+
         requests_item = {}
         requests_item[project_to_create] = []
         print '\n  >>>> Processing target %s\n  >>>> %s\n' % (target_project, project_to_create)
@@ -208,15 +208,21 @@ def main():
                     smtr = item.get('submitter')
                     sn = item.get('snapshot')
                     bSetHighlight = True
+                    bDeleted = False
                     for item in mapping:
                         # We only care about defined git repositories
                         if item.get('OBS_project', '') == target['target'] and \
                             item.get('Project_name', '') == target_fork_prefix + repo:
                             bSetHighlight = False
+                        if item.get('OBS_project', '') == target['target'] and \
+                            item.get('Project_name', '') == repo:
+                            bSetHighlight = False
+                            bDeleted = True
+
                     if bSetHighlight:
-                        marked_repo = {'repo': HIGHLIGHT + repo, 'cid': cid, 'submitter': smtr, 'snapshot': sn}
+                        marked_repo = {'repo': HIGHLIGHT + repo, 'cid': cid, 'submitter': smtr, 'snapshot': sn, 'deleted': bDeleted}
                     else:
-                        marked_repo = {'repo': GREYEDOUT + repo, 'cid': cid, 'submitter': smtr, 'snapshot': sn}
+                        marked_repo = {'repo': GREYEDOUT + repo, 'cid': cid, 'submitter': smtr, 'snapshot': sn, 'deleted': bDeleted}
                     if marked_repo not in _sr_list[_sr_tag]:
                         _sr_list[_sr_tag].append(marked_repo)
                 if _sr_list[_sr_tag]:
@@ -237,19 +243,24 @@ def main():
                         smtr = item.get('submitter')
                         sn = item.get('snapshot')
                         _package = ''
+
                         if True:#git.startswith(HIGHLIGHT):
                             _tag_info = get_info_from_tag(git[1:], source_branch, project, \
                                                           submit, GerritEnv('PUBLIC_'))
                             _package = _tag_info.get('spec_name', None)
                             _commit_id = _tag_info.get('commit_id', None)
+                            if _package is None:
+                                _package = os.path.basename(git)
                             if _package and _commit_id:
                                 requests_item[project_to_create].append({'package': _package, \
                                                                          'git_tag': submit, \
                                                                          'cid': _commit_id, \
                                                                          'submitter': smtr, \
                                                                          'gerrit_project': git, \
+                                                                         'deleted': item.get('deleted'), \
                                                                          'snapshot': sn})
 
+
         # Split request into smaller part
         split_step = 100
         for r in xrange(0, len(requests_item[project_to_create]), split_step):