Raise obs error if Base project is empty
authorZhang Qiang <qiang.z.zhang@intel.com>
Fri, 30 Mar 2012 07:20:42 +0000 (15:20 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Fri, 30 Mar 2012 07:20:42 +0000 (15:20 +0800)
gitbuildsys/cmd_build.py
gitbuildsys/obspkg.py

index 4c0c9364a674d5295c7e416a3201ff783d43fb54..913bd9d023f303f4b6d2ccfbee8a7647b631cd4e 100644 (file)
@@ -31,6 +31,7 @@ import utils
 from conf import configmgr
 import git
 import obspkg
+import errors
 
 OSCRC_TEMPLATE = """[general]
 apiurl = %(apiurl)s
@@ -104,7 +105,10 @@ def do(opts, args):
     msger.info('checking status of obs project: %s ...' % target_prj)
     if prj.is_new():
         msger.info('creating %s for package build ...' % target_prj)
-        prj.branch_from(base_prj)
+        try:
+            prj.branch_from(base_prj)
+        except errors.ObsError, e:
+            msger.error('%s' % e)
 
     msger.info('checking out %s/%s to %s ...' % (target_prj, name, tmpdir))
     localpkg = obspkg.ObsPackage(tmpdir, target_prj, name, APISERVER, oscrcpath)
index 85f8cc62d696b41663b60f922befda4c4ac7557e..8fa009057dc99624c83d70b26954770f2bd2a0b3 100644 (file)
@@ -175,7 +175,10 @@ class ObsProject(object):
             return
 
         # pick the 1st valid package inside src prj FIXME
-        dumb_pkg = self._bs.getPackageList(src_prj)[0]
+        pkglist = self._bs.getPackageList(src_prj)
+        if len(pkglist) == 0:
+            raise errors.ObsError('base project %s is empty.' % src_prj)
+        dumb_pkg = pkglist[0]
 
         # branch out the new one
         target_prj, target_pkg = self._bs.branchPkg(src_prj, dumb_pkg,
@@ -183,7 +186,7 @@ class ObsProject(object):
                                                     target_package = 'dumb_pkg')
 
         if target_prj != self._prj:
-            raise ObsError('branched prj: %s is not the expected %s' \
+            raise errors.ObsError('branched prj: %s is not the expected %s' \
                            % (target_prj, self._prj))
 
         # remove the dumb pkg