feat: add submodule check before committing and pushing
This commit is contained in:
@@ -57,7 +57,20 @@ Analyze the following git diff and generate a commit message:
|
|||||||
return str(response).strip()
|
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():
|
async def get_submodule_info():
|
||||||
|
if not await has_submodules():
|
||||||
|
return {}
|
||||||
|
|
||||||
proc = await asyncio.create_subprocess_exec(
|
proc = await asyncio.create_subprocess_exec(
|
||||||
"git", "config", "--file", ".gitmodules", "--get-regexp", r"^submodule\..*\.path$",
|
"git", "config", "--file", ".gitmodules", "--get-regexp", r"^submodule\..*\.path$",
|
||||||
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE,
|
||||||
@@ -80,6 +93,10 @@ async def get_submodule_info():
|
|||||||
|
|
||||||
|
|
||||||
async def commit_and_push_submodules():
|
async def commit_and_push_submodules():
|
||||||
|
if not await has_submodules():
|
||||||
|
print("No submodules found in this repository.")
|
||||||
|
return
|
||||||
|
|
||||||
print("Checking for submodule changes...")
|
print("Checking for submodule changes...")
|
||||||
submodule_info = await get_submodule_info()
|
submodule_info = await get_submodule_info()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user