diff options
author | Jesse Keating <jkeating@redhat.com> | 2010-08-12 00:23:07 -0700 |
---|---|---|
committer | Jesse Keating <jkeating@redhat.com> | 2010-08-12 00:23:07 -0700 |
commit | 2a01e0e40df26e458597b3ffebcdd76233abba01 (patch) | |
tree | 0fd4bb724dafec9ddebb6bc4fc954431e8cb3bb5 | |
parent | 1401d6e1c366e3ae34685d4b3f62cf7afaeb3885 (diff) | |
download | fedora-packager-2a01e0e40df26e458597b3ffebcdd76233abba01.tar.gz fedora-packager-2a01e0e40df26e458597b3ffebcdd76233abba01.tar.xz fedora-packager-2a01e0e40df26e458597b3ffebcdd76233abba01.zip |
Trap attempts to make git repos. #622716
-rw-r--r-- | src/pyfedpkg/__init__.py | 14 |
1 files 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 |