It seems the directory does not exist. Could you check the directory structure and ensure the correct directory is specified?
This commit is contained in:
parent
6ec2257634
commit
58b9e0874b
@ -67,23 +67,80 @@ def gen_commit(project_path):
|
|||||||
return str(response).strip()
|
return str(response).strip()
|
||||||
|
|
||||||
|
|
||||||
|
async def get_submodule_info():
|
||||||
|
"""Get submodule information including path and remote URL."""
|
||||||
|
proc = await asyncio.create_subprocess_exec(
|
||||||
|
"git", "config", "--file", ".gitmodules", "--get-regexp", "^submodule\..*\.path$",
|
||||||
|
stdout=asyncio.subprocess.PIPE,
|
||||||
|
stderr=asyncio.subprocess.PIPE,
|
||||||
|
)
|
||||||
|
stdout, stderr = await proc.communicate()
|
||||||
|
|
||||||
|
if stderr:
|
||||||
|
print(f"Error getting submodule paths:\n{stderr.decode()}")
|
||||||
|
return {}
|
||||||
|
|
||||||
|
submodule_info = {}
|
||||||
|
for line in stdout.decode().splitlines():
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
|
# Parse the line like "submodule.submodule-name.path path/to/submodule"
|
||||||
|
parts = line.split()
|
||||||
|
if len(parts) == 2:
|
||||||
|
name = parts[0].split('.')[1]
|
||||||
|
path = parts[1]
|
||||||
|
submodule_info[path] = name
|
||||||
|
|
||||||
|
return submodule_info
|
||||||
|
|
||||||
|
|
||||||
async def commit_submodules():
|
async def commit_submodules():
|
||||||
"""Commit uncommitted changes in submodules (if any)."""
|
"""Commit uncommitted changes in submodules (if any)."""
|
||||||
print("Checking for submodule changes...")
|
print("Checking for submodule changes...")
|
||||||
|
|
||||||
|
# Get submodule information
|
||||||
|
submodule_info = await get_submodule_info()
|
||||||
|
|
||||||
|
# Get list of submodules with changes
|
||||||
proc = await asyncio.create_subprocess_shell(
|
proc = await asyncio.create_subprocess_shell(
|
||||||
"git submodule foreach --quiet '"
|
"git submodule foreach --quiet '"
|
||||||
"if [ -n \"$(git status --porcelain)\" ]; then "
|
"if [ -n \"$(git status --porcelain)\" ]; then "
|
||||||
"echo Committing submodule: $name; "
|
"echo $path; "
|
||||||
"git add . && git commit -m \"Auto-commit submodule changes\" || true; "
|
|
||||||
"fi'",
|
"fi'",
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
stderr=asyncio.subprocess.PIPE,
|
stderr=asyncio.subprocess.PIPE,
|
||||||
)
|
)
|
||||||
stdout, stderr = await proc.communicate()
|
stdout, stderr = await proc.communicate()
|
||||||
if stdout:
|
|
||||||
print(stdout.decode())
|
|
||||||
if stderr:
|
if stderr:
|
||||||
print(f"Submodule commit stderr:\n{stderr.decode()}")
|
print(f"Error checking submodules:\n{stderr.decode()}")
|
||||||
|
return
|
||||||
|
|
||||||
|
submodule_paths = stdout.decode().strip().split('\n')
|
||||||
|
|
||||||
|
# Process each submodule with changes
|
||||||
|
for submodule_path in submodule_paths:
|
||||||
|
if not submodule_path:
|
||||||
|
continue
|
||||||
|
|
||||||
|
submodule_name = submodule_info.get(submodule_path, submodule_path)
|
||||||
|
print(f"Processing submodule: {submodule_name} at {submodule_path}")
|
||||||
|
|
||||||
|
# Generate commit message for submodule
|
||||||
|
commit_msg = gen_commit(submodule_path)
|
||||||
|
|
||||||
|
# Commit changes with generated message
|
||||||
|
proc = await asyncio.create_subprocess_shell(
|
||||||
|
f"cd {submodule_path} && git add . && git commit -m \"{commit_msg}\" || true",
|
||||||
|
stdout=asyncio.subprocess.PIPE,
|
||||||
|
stderr=asyncio.subprocess.PIPE,
|
||||||
|
)
|
||||||
|
stdout, stderr = await proc.communicate()
|
||||||
|
|
||||||
|
if stdout:
|
||||||
|
print(stdout.decode())
|
||||||
|
if stderr:
|
||||||
|
print(f"Submodule commit stderr for {submodule_name}:\n{stderr.decode()}")
|
||||||
|
|
||||||
|
|
||||||
async def push_code():
|
async def push_code():
|
||||||
|
Loading…
Reference in New Issue
Block a user