From: Zhang Qiang Date: Mon, 2 Jul 2012 02:29:00 +0000 (+0800) Subject: Check branch to fix backtrace issue if no branch X-Git-Tag: 0.8~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=051c47f87711da39859b0e5b4eb8d2fd5b6566a7;p=tools%2Fgbs.git Check branch to fix backtrace issue if no branch use git-buildpackage error directly, fix #85 and #110 --- diff --git a/gitbuildsys/cmd_build.py b/gitbuildsys/cmd_build.py index 756fcf5..7076aac 100644 --- a/gitbuildsys/cmd_build.py +++ b/gitbuildsys/cmd_build.py @@ -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 diff --git a/gitbuildsys/cmd_changelog.py b/gitbuildsys/cmd_changelog.py index 5051f8e..356dc90 100644 --- a/gitbuildsys/cmd_changelog.py +++ b/gitbuildsys/cmd_changelog.py @@ -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 diff --git a/gitbuildsys/cmd_export.py b/gitbuildsys/cmd_export.py index 2e64129..8575008 100644 --- a/gitbuildsys/cmd_export.py +++ b/gitbuildsys/cmd_export.py @@ -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 diff --git a/gitbuildsys/cmd_remotebuild.py b/gitbuildsys/cmd_remotebuild.py index c909c65..a8d383b 100644 --- a/gitbuildsys/cmd_remotebuild.py +++ b/gitbuildsys/cmd_remotebuild.py @@ -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