Catch exception when git describe
authorLin Yang <lin.a.yang@intel.com>
Mon, 1 Jul 2013 02:58:27 +0000 (10:58 +0800)
committerGerrit Code Review <gerrit2@otctools.jf.intel.com>
Mon, 1 Jul 2013 07:08:37 +0000 (00:08 -0700)
Change-Id: I0c5b19348ae8b4a09f884929dd40aa129a6b3ebb
Signed-off-by: Lin Yang <lin.a.yang@intel.com>
job_submitobs.py

index d48e1eb..473e419 100755 (executable)
@@ -23,6 +23,7 @@ from common import gerrit
 from common.send_mail import prepare_mail
 
 import gbp.rpm
+from gbp.git.repository import GitRepositoryError
 
 WRONG_VERSION_MSG = '- The tag means you want to submit commit %s in %s branch'\
                     ' to OBS, but this commit does NOT exist in %s branch. '\
@@ -88,8 +89,12 @@ def find_submit_tag(event, mygit):
         branch = event['branch']
         if event['branch'] == 'master':
             branch = 'trunk'
-        tag = mygit.describe(event['patchset_revision'], pattern='submit/%s/*'
-                % branch, exact_match=True)
+        try:
+            tag = mygit.describe(event['patchset_revision'], pattern='submit/%s/*'
+                    % branch, exact_match=True)
+        except GitRepositoryError, err:
+            # don'n find submit tag on this commit, return None
+            tag = None
 
     return tag