Merge ~darinmiller/ka:master into ka:master

Proposed by Darin Miller on 2017-04-29
Status: Merged
Merged at revision: 02c2c37623b9bf18a7826f199950ea4516094bdf
Proposed branch: ~darinmiller/ka:master
Merge into: ka:master
Diff against target: 23 lines (+6/-1)
1 file modified
lib/git_checks.py (+6/-1)
Reviewer Review Type Date Requested Status
Kubuntu Packagers 2017-04-29 Pending
Review via email: mp+323422@code.launchpad.net

Description of the Change

Fixed git_checks.py to fail gracefully on failed git assignment

To post a comment you must log in.

Hi, the change seems good, however, apparently there's another place to put a try-except:

user@host:/tmp$ uploadsource
Traceback (most recent call last):
  File "/home/santa/kubuntu-automation/uploadsource", line 54, in <module>
    checkUnpushedGitChanges()
  File "/home/santa/kubuntu-automation/lib/git_checks.py", line 50, in checkUnpushedGitChanges
    git_repo = Repo('.')
  File "/usr/lib/python3/dist-packages/git/repo/base.py", line 168, in __init__
    raise InvalidGitRepositoryError(epath)
git.exc.InvalidGitRepositoryError: /tmp

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/git_checks.py b/lib/git_checks.py
2index 565cd8a..548caaf 100644
3--- a/lib/git_checks.py
4+++ b/lib/git_checks.py
5@@ -13,12 +13,17 @@
6 ############################################################################
7
8 import sys
9+import os
10
11 from git import Repo
12
13 #Check if the current branch is a valid Kubuntu branch
14 def kubuntuCheckValidBranch(distribution=None):
15- git_repo = Repo('.')
16+ try:
17+ git_repo = Repo('.')
18+ except:
19+ print("Git repo not found here, 'pwd': " + os.getcwd())
20+ sys.exit(1)
21 branch_name = str(git_repo.active_branch)
22 branch_name_parts = branch_name.split('_')
23 warning = ''

Subscribers

People subscribed via source and target branches