From 6c9206d6e9f64b2626b3d7f81780a7cf7879b37c Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Mon, 31 Jan 2011 12:59:36 -0700 Subject: Catch a traceback when trying to build from local branch When the local branch doesn't have a merge point, catch people trying to build from a remote url. --- src/pyfedpkg/__init__.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/pyfedpkg') diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py index 9c1adf3..76b4e5d 100644 --- a/src/pyfedpkg/__init__.py +++ b/src/pyfedpkg/__init__.py @@ -1182,13 +1182,16 @@ class PackageModule: # Need to check here to see if the local commit you want to build is # pushed or not branch = self.repo.active_branch - remote = self.repo.git.config('--get', - 'branch.%s.remote' % branch) - - merge = self.repo.git.config('--get', - 'branch.%s.merge' % branch).replace('refs/heads', remote) - if self.repo.git.rev_list('%s...%s' % (branch, merge)): - raise FedpkgError('There are unpushed changes in your repo') + try: + remote = self.repo.git.config('--get', + 'branch.%s.remote' % branch) + + merge = self.repo.git.config('--get', + 'branch.%s.merge' % branch).replace('refs/heads', remote) + if self.repo.git.rev_list('%s...%s' % (branch, merge)): + raise FedpkgError('There are unpushed changes in your repo') + except git.errors.GitCommandError: + raise FedpkgError('You must provide a srpm or push your changes to origin.') # Get the commit hash to build commit = self.repo.iter_commits().next().sha url = ANONGITURL % {'module': self.module} + '?#%s' % commit -- cgit