Этот код здесь должен иметь возможность обновить несколько репо и создавать новые филиалы, и он должен Уметь создавать новые запросы на слияние
Этот код здесь должен иметь возможность обновить несколько репо и создавать новые филиалы, и он должен быть в состоянии создать новые запросы на объединение
Этот код здесь должен иметь возможность разбиться с множественным обновлением Репо и создавать новые филиалы, и они должны иметь возможность создавать новые запросы на слияние < /p>
def run_command(command, repo_path):
"""Runs a shell command in the given repository."""
try:
result = subprocess.run(command, cwd=repo_path, shell=True, check=True, capture_output=True, text=True)
return result.stdout.strip()
except subprocess.CalledProcessError as e:
print(f"Error in {repo_path}: {e.stderr.strip()}")
return None
def process_repo(repo):
"""Processes a single Git repository."""
repo_path = os.path.join(PARENT_DIR, repo)
os.path.isdir(os.path.join(repo_path, ".git")):
print(f"Skipping {repo} (not a Git repo)")
return
print(f"\nProcessing repository: {repo}")
run_command(f"git fetch {REMOTE}", repo_path)
if run_command(f"git checkout {TARGET_BRANCH}", repo_path) is None:
print(f"Skipping {repo} (no {TARGET_BRANCH} branch)")
return
run_command(f"git pull {REMOTE} {TARGET_BRANCH}", repo_path)
run_command(f"git checkout -b {BRANCH_NAME}", repo_path)
file_path = os.path.join(repo_path, "automation.txt")
with open(file_path, "a") as f:
f.write("Updated by script\n")
run_command(f"git add automation.txt", repo_path)
run_command(f'git commit -m "{COMMIT_MSG}"', repo_path)
run_command(f"git push -u {REMOTE} {BRANCH_NAME}", repo_path)
run_command(f'glab mr create --source-branch {BRANCH_NAME} --target-branch {TARGET_BRANCH} --title "Merge {BRANCH_NAME}" --description "Automated merge request"', repo_path)
if __name__ == "__main__":
for repo in os.listdir(PARENT_DIR):
if os.path.isdir(os.path.join(PARENT_DIR, repo)):
process_repo(repo)
print("\n
'''
This code here should be able to bulk update multiple repos and create new branches and it should be able to create new Merge requests
This code here should be able to bulk update multiple repos and create new branches and it should be able to create new Merge requests
This code here should be able to bulk update multiple repos and create new branches and it should be able to create new Merge requests
This code here should be able to bulk update multiple repos and create new branches and it should be able to create new Merge requests
Подробнее здесь: https://stackoverflow.com/questions/794 ... date-repos