Check branch to fix backtrace issue if no branch
authorZhang Qiang <qiang.z.zhang@intel.com>
Mon, 2 Jul 2012 02:29:00 +0000 (10:29 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Wed, 4 Jul 2012 01:50:31 +0000 (09:50 +0800)
use git-buildpackage error directly, fix #85 and #110

gitbuildsys/cmd_build.py
gitbuildsys/cmd_changelog.py
gitbuildsys/cmd_export.py
gitbuildsys/cmd_remotebuild.py

index 756fcf5d5b4ab9ebf2bb8398d17c3729d921c8b8..7076aacab12e0a9b413576ca409478115fcfda76 100644 (file)
@@ -236,8 +236,10 @@ def do(opts, args):
 
     try:
         repo = RpmGitRepository(workdir)
-    except GitRepositoryError:
-        msger.error("%s is not a git repository" % (workdir))
+        if repo.get_branch() is None:
+            msger.error('currently not on a branch')
+    except GitRepositoryError, err:
+        msger.error(str(err))
 
     workdir = repo.path
 
index 5051f8ee970c12837d5690fca7a32e4ec12440eb..356dc90514933bd493e020ec813c0559dc27bb31 100644 (file)
@@ -92,8 +92,10 @@ def do(opts, _args):
 
     try:
         repo = RpmGitRepository('.')
-    except GitRepositoryError:
-        msger.error("No git repository found.")
+        if repo.get_branch() is None:
+            msger.error('currently not on a branch')
+    except GitRepositoryError, err:
+        msger.error(str(err))
 
     project_root_dir = repo.path
 
index 2e64129519de52d12e17fb5872ac485e0face7ce..857500844845121b0481e314d0c50eae83c76c4f 100644 (file)
@@ -59,8 +59,10 @@ def do(opts, args):
 
     try:
         repo = RpmGitRepository(workdir)
-    except GitRepositoryError:
-        msger.error("%s is not a git repository" % (workdir))
+        if repo.get_branch() is None:
+            msger.error('currently not on a branch')
+    except GitRepositoryError, err:
+        msger.error(str(err))
 
     workdir = repo.path
 
index c909c65a070d035502acdb0c88a78be2e8c1fd8f..a8d383bf8db976b949945438e7e3e4db1ba7cebe 100644 (file)
@@ -74,8 +74,10 @@ def do(opts, args):
 
     try:
         repo = RpmGitRepository(workdir)
-    except GitRepositoryError:
-        msger.error('%s is not a git dir' % workdir)
+        if repo.get_branch() is None:
+            msger.error('currently not on a branch')
+    except GitRepositoryError, err:
+        msger.error(str(err))
 
     workdir = repo.path