diff --git a/scripts/interpreter/gen_commit.py b/scripts/interpreter/gen_commit.py index e7b91e6..a62c776 100755 --- a/scripts/interpreter/gen_commit.py +++ b/scripts/interpreter/gen_commit.py @@ -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()