feat(interpreter): handle repos without submodules in commit process

This commit is contained in:
KaySar12 2025-05-15 18:12:50 +07:00
parent 056d090ea4
commit e8b7c38961

View File

@ -57,7 +57,20 @@ Analyze the following git diff and generate a commit message:
return str(response).strip()
async def has_submodules():
"""Check if the repository has any submodules."""
proc = await asyncio.create_subprocess_exec(
"git", "config", "--file", ".gitmodules", "--get-regexp", r"^submodule\.",
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
)
stdout, stderr = await proc.communicate()
return bool(stdout.decode().strip())
async def get_submodule_info():
if not await has_submodules():
return {}
proc = await asyncio.create_subprocess_exec(
"git", "config", "--file", ".gitmodules", "--get-regexp", r"^submodule\..*\.path$",
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
@ -80,6 +93,10 @@ async def get_submodule_info():
async def commit_and_push_submodules():
if not await has_submodules():
print("No submodules found in this repository.")
return
print("Checking for submodule changes...")
submodule_info = await get_submodule_info()