Quit execution when tag is deleted
authorLin Yang <lin.a.yang@intel.com>
Mon, 17 Sep 2012 06:54:45 +0000 (14:54 +0800)
committerLin Yang <lin.a.yang@intel.com>
Mon, 17 Sep 2012 06:54:45 +0000 (14:54 +0800)
job_submitobs.py

index 789a17b..a402aef 100755 (executable)
@@ -217,6 +217,15 @@ def check_tag_format(tag, git, gerrit):
 
     return result
 
+def is_tag_deleted(oldrev, newrev):
+    """check whehter tag is deleted"""
+
+    # 0000*0 is a special git hash code in gerrit for deleted git object
+    if oldrev != newrev and newrev == '0000000000000000000000000000000000000000':
+        return True
+    else:
+        return False
+
 def main():
     # global variable
     global GERRIT_PATCHSET_REVISION
@@ -227,6 +236,9 @@ def main():
         if not GERRIT_REFNAME.startswith('refs/tags/submit/'):
             print '\nREFNAME "%s" isn\'t start with refs/tags/submit, exit now' % GERRIT_REFNAME
             end('success')
+        elif is_tag_deleted(GERRIT_OLDREV, GERRIT_NEWREV):
+            print '\nREFNAME "%s" is deleted, exit now' % GERRIT_REFNAME
+            end('success')
 
     # check whether exist git-obs-mapping.xml in local
     if GERRIT_PROJECT == MAPPING_PRJ or not os.path.isfile('%s/%s/git-obs-mapping.xml' % (GIT_CACHE_DIR, MAPPING_PRJ)):