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 756fcf5..7076aac 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 5051f8e..356dc90 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 2e64129..8575008 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 c909c65..a8d383b 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