From 32465a8f110fc8ecfe489f66679cfc9d448fc1b4 Mon Sep 17 00:00:00 2001 From: Travis Dent Date: Mon, 17 Feb 2025 16:39:26 -0800 Subject: [PATCH] Silently ignore gitpython import errors. --- agentstack/repo.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/agentstack/repo.py b/agentstack/repo.py index f1e10465..0ead48b0 100644 --- a/agentstack/repo.py +++ b/agentstack/repo.py @@ -1,11 +1,10 @@ from typing import Optional +from types import ModuleType from pathlib import Path import shutil -import git from agentstack import conf, log from agentstack.exceptions import EnvironmentError - MAIN_BRANCH_NAME = "main" AUTOMATION_NOTE = "\n\n(This commit was made automatically by AgentStack)" @@ -15,6 +14,14 @@ _USE_GIT = None # global state to disable git for this run +# The python git module prints an excessive error message when git is not +# installed. We always want to allow git support to fail silently. +try: + import git +except ImportError: + _USE_GIT = False + + def should_track_changes() -> bool: """ If git has been disabled for this run, return False. Next, look for the value