Fix bug on submit tag check
authorLin Yang <lin.a.yang@intel.com>
Wed, 14 May 2014 08:25:59 +0000 (16:25 +0800)
committerLin Yang <lin.a.yang@intel.com>
Wed, 14 May 2014 10:12:53 +0000 (18:12 +0800)
Jenkins should check whether the submit tag has been merged into git tree, if
not, then check whether it is still open on gerrit. It will give out mistake
message if check on gerrit at first.

Fixes: #1876

Change-Id: I72b6a0bacdb427b69a33cc16e77a89820c8672ec
Signed-off-by: Lin Yang <lin.a.yang@intel.com>
job_submitobs.py

index 2be0d11..6ed4432 100755 (executable)
@@ -123,18 +123,19 @@ def check_tag_format(git, mygerrit, event, tag):
         if not pattern.match(date):
             message.append(WRONG_DATE_MSG % date)
 
-        # Check if change is still under review
-        cmd = '--current-patch-set status: open project: %s commit: %s' % \
-                  (event['project'], psr)
-        gerritinfo = mygerrit.query(cmd)
-        if len(gerritinfo) == 1 and 'number' in gerritinfo[0] \
-                and 'currentPatchSet' in gerritinfo[0]:
-            if gerritinfo[0]['branch'] == branch:
-                # the tagged commit still open, abort submit this time
-                message.append(UNDER_REVIEW_MSG % (tag, psr))
-        else:
-            # cannot find tagged commit in git tree or gerrit open change
-            message.append(WRONG_COMMIT_MSG % psr)
+        if not git.branch_contains(tag):
+            # Check if change is still under review
+            cmd = '--current-patch-set status: open project: %s commit: %s' % \
+                      (event['project'], psr)
+            gerritinfo = mygerrit.query(cmd)
+            if len(gerritinfo) == 1 and 'number' in gerritinfo[0] \
+                    and 'currentPatchSet' in gerritinfo[0]:
+                if gerritinfo[0]['branch'] == branch:
+                    # the tagged commit still open, abort submit this time
+                    message.append(UNDER_REVIEW_MSG % (tag, psr))
+            else:
+                # cannot find tagged commit in git tree or gerrit open change
+                message.append(WRONG_COMMIT_MSG % psr)
     else:
         # wrong tag format
         message.append(UNKNOWN_FORMAT_MSG)