Skip to content

Commit 0414fc8

Browse files
authored
Merge pull request #319 from tcdent/git-import
Silently ignore gitpython import errors.
2 parents bf38f34 + d09b3fa commit 0414fc8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

agentstack/repo.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from typing import Optional
2+
from types import ModuleType
23
from pathlib import Path
34
import shutil
4-
import git
55
from agentstack import conf, log
66
from agentstack.exceptions import EnvironmentError
77

8-
98
MAIN_BRANCH_NAME = "main"
109

1110
AUTOMATION_NOTE = "\n\n(This commit was made automatically by AgentStack)"
@@ -15,6 +14,14 @@
1514
_USE_GIT = None # global state to disable git for this run
1615

1716

17+
# The python git module prints an excessive error message when git is not
18+
# installed. We always want to allow git support to fail silently.
19+
try:
20+
import git
21+
except ImportError:
22+
_USE_GIT = False
23+
24+
1825
def should_track_changes() -> bool:
1926
"""
2027
If git has been disabled for this run, return False. Next, look for the value

0 commit comments

Comments
 (0)