From 2a01e0e40df26e458597b3ffebcdd76233abba01 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Thu, 12 Aug 2010 00:23:07 -0700 Subject: Trap attempts to make git repos. #622716 --- src/pyfedpkg/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py index acf9eeb..9acdf82 100644 --- a/src/pyfedpkg/__init__.py +++ b/src/pyfedpkg/__init__.py @@ -64,8 +64,8 @@ def _find_branch(path=os.getcwd(), repo=None): if not repo: try: repo = git.Repo(path) - except: - raise FedpkgError('Invalid repo %s' % path) + except git.errors.InvalidGitRepositoryError: + raise FedpkgError('%s is not a valid repo' % path) return(repo.active_branch.name) # Define some helper functions, they start with _ @@ -227,7 +227,10 @@ def _list_branches(path=os.getcwd(), repo=None): # Create the repo from path if no repo passed if not repo: - repo = git.Repo(path) + try: + repo = git.Repo(path) + except git.errors.InvalidGitRepositoryError: + raise FedpkgError('%s is not a valid repo' % path) log.debug('Listing refs') refs = repo.refs # Sort into local and remote branches @@ -446,7 +449,10 @@ def import_srpm(srpm, path=os.getcwd()): if not os.path.exists(srpm): raise FedpkgError('File not found.') # bail if we're dirty - repo = git.Repo(path) + try: + repo = git.Repo(path) + except git.errors.InvalidGitRepositoryError: + raise FedpkgError('%s is not a valid repo' % path) if repo.is_dirty(): raise FedpkgError('There are uncommitted changes in your repo') # Get the details of the srpm -- cgit