Skip to content

Commit

Permalink
Added further checks to handle git not found exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlin7 authored Jul 7, 2023
1 parent 7987bb2 commit c0bb977
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions biscuit/core/components/git/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from tkinter import messagebox

git_available = True
try:
import git
from .repo import GitRepo
except ImportError:
messagebox.showerror("Git not found", "Git is not installed on your PC. Install Git and add Git to the PATH to use Biscuit")

git_available = False

class Git(git.Git):
def __init__(self, master, *args, **kwargs):
Expand All @@ -14,7 +16,7 @@ def __init__(self, master, *args, **kwargs):
self.repo = None

def check_git(self):
if not self.base.active_directory:
if not (git_available and self.base.active_directory):
self.base.git_found = False
return

Expand All @@ -25,8 +27,14 @@ def check_git(self):
self.base.git_found = False

def get_version(self):
if not git_available:
return

return self.version()

@property
def active_branch(self):
if not git_available:
return

return self.repo.active_branch

0 comments on commit c0bb977

Please sign in to comment.