ABS - update strict commit and tag with extention 25/170725/1
authorhyokeun <hyokeun.jeon@samsung.com>
Thu, 22 Feb 2018 00:43:00 +0000 (09:43 +0900)
committerhyokeun <hyokeun.jeon@samsung.com>
Thu, 22 Feb 2018 00:43:06 +0000 (09:43 +0900)
Change-Id: Id2f0f11b8626edfafe24081be38d7c31acf5031e

abs/job_update_abs_rbs_status_for_dashboard.py

index 2820e85..c6b9241 100644 (file)
@@ -44,6 +44,7 @@ from common.workflow import find_specfile, parse_specfile
 from common.utils import unicode_to_str
 
 from common import buildmonitor_db
+from common.buildmonitor_extention import BuildMonitorExtention
 
 # set default char-set endcoding to utf-8
 reload(sys)
@@ -66,7 +67,7 @@ def update_tizen_studio(param):
         query = 'INSERT INTO tizen_studio (version, distribution) VALUES(%s, %s)'
         buildmonitor_db.do_query(query, (tizen_studio_version, tizen_studio_distribution))
 
-def update_rootstrap_status(param):
+def update_rootstrap_status(bm_ext, param):
 
     event_info = parse_input_parameters(param)
     project           = event_info.get('project', None)
@@ -126,7 +127,7 @@ def get_git_tag_id(git_commit_id, tag_name, tag_revision):
     git_tag_id = buildmonitor_db.get_value_from_query_data(query, (git_commit_id, tag_name, tag_revision))
     return git_tag_id
 
-def update_commit_tag_for_abs(param):
+def update_commit_tag_for_abs(bm_ext, param):
 
     event_info = parse_input_parameters(param)
 
@@ -155,7 +156,8 @@ def update_commit_tag_for_abs(param):
         and commit_date is not None \
         and committer is not None \
         and commit_message is not None:
-        update_commit(git_path_id, commit_id, commit_date, committer, commit_message)
+        branch = '/'.join(tag_name.replace('submit/','').split('/')[:-1])
+        bm_ext.update_git_commit_strict(git_path, commit_id, committer, commit_date, commit_message, branch)
 
     #Find commit id
     git_commit_id = get_git_commit_id(git_path, commit_id)
@@ -169,7 +171,7 @@ def update_commit_tag_for_abs(param):
         and tagger is not None \
         and tag_date is not None \
         and tag_message is not None:
-        update_tag(git_commit_id, tag_name, tag_revision, tagger, tag_date, tag_message)
+        bm_ext.update_git_tag_strict(git_commit_id, tag_name, tag_revision, tagger, tag_date, tag_message)
 
     #Find tag id
     git_tag_id = get_git_tag_id(git_commit_id, tag_name, tag_revision)
@@ -180,17 +182,18 @@ def update_commit_tag_for_abs(param):
 def reform_param(param):
     return param.replace('None', '""')
 
-def start_abs(param):
+def start_abs(bm_ext, param):
 
     event_info = parse_input_parameters(param)
 
-    git_path_id, git_commit_id, git_tag_id = update_commit_tag_for_abs(param)
+    git_path_id, git_commit_id, git_tag_id = update_commit_tag_for_abs(bm_ext, param)
     print '\n\n========'
     print git_path_id, git_commit_id, git_tag_id
     print '========\n\n'
 
     #TODO: Update abs status
-    update_abs_status(event_info.get('type'), \
+    update_abs_status(bm_ext,
+                      event_info.get('type'), \
                       event_info.get('project'), \
                       event_info.get('status'), \
                       event_info.get('status_reason'), \
@@ -201,7 +204,7 @@ def start_abs(param):
                       event_info.get('tizen_studio_version'), \
                       event_info.get('tizen_studio_distribution'))
 
-def update_abs_status(mode, main_project, status, status_reason, source_git_tag_id, tpk_git_tag, obs_package_name, rootstrap_version, tizen_studio_version, tizen_studio_distribution):
+def update_abs_status(bm_ext, mode, main_project, status, status_reason, source_git_tag_id, tpk_git_tag, obs_package_name, rootstrap_version, tizen_studio_version, tizen_studio_distribution):
 
     # Find main project id
     query = 'SELECT id FROM main_project WHERE name=%s'
@@ -278,9 +281,9 @@ def update_abs_status(mode, main_project, status, status_reason, source_git_tag_
         query_data += (abs_status_id,)
         buildmonitor_db.do_query(query, query_data)
 
-def finish_abs(param):
+def finish_abs(bm_ext, param):
 
-    git_path_id, git_commit_id, git_tag_id = update_commit_tag_for_abs(param)
+    git_path_id, git_commit_id, git_tag_id = update_commit_tag_for_abs(bm_ext, param)
     print '\n\n========'
     print git_path_id, git_commit_id, git_tag_id
     print '========\n\n'
@@ -293,15 +296,16 @@ def main():
     rootstrap_version = os.getenv('ROOTSTRAP_VERSION', None)
 
     buildmonitor_db.connect_db()
+    bm_ext = BuildMonitorExtention()
 
     try:
         #TODO: Update RBS status
         if event_type == 'ROOTSTRAP_UPDATED':
-            update_rootstrap_status(os.getenv(event_type))
+            update_rootstrap_status(bm_ext, os.getenv(event_type))
         elif event_type == 'START_ABS':
-            start_abs(os.getenv(event_type))
+            start_abs(bm_ext, os.getenv(event_type))
         elif event_type == 'FINISH_ABS':
-            finish_abs(os.getenv(event_type))
+            finish_abs(bm_ext, os.getenv(event_type))
     except Exception as err:
         buildmonitor_db.disconnect_db()
         print repr(err)