mirror of
https://github.com/bjoernellens1/cps_loki.git
synced 2024-11-23 07:35:09 +00:00
Update initialize.py
Update reading from repos.yaml file
This commit is contained in:
parent
db333799f7
commit
298e8ad74f
@ -1,5 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import yaml
|
||||||
|
|
||||||
class GitCloner:
|
class GitCloner:
|
||||||
def __init__(self, directory):
|
def __init__(self, directory):
|
||||||
@ -16,18 +17,20 @@ class GitCloner:
|
|||||||
command = ['git', 'clone', '--branch', branch, repo_url, repo_path]
|
command = ['git', 'clone', '--branch', branch, repo_url, repo_path]
|
||||||
try:
|
try:
|
||||||
subprocess.check_output(command)
|
subprocess.check_output(command)
|
||||||
print(f"Successfully cloned repository '{repo_name}'.")
|
print(f"Successfully cloned repository '{repo_name}' on branch '{branch}'.")
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
print(f"Failed to clone repository '{repo_name}': {e}")
|
print(f"Failed to clone repository '{repo_name}' on branch '{branch}': {e}")
|
||||||
|
|
||||||
|
|
||||||
# Usage example
|
# Usage example
|
||||||
cloner = GitCloner('./src')
|
cloner = GitCloner('./src')
|
||||||
|
|
||||||
# Load repository URLs from file
|
# Load repository URLs from YAML file
|
||||||
with open('repos.txt', 'r') as file:
|
with open('repos.yaml', 'r') as file:
|
||||||
repos = file.readlines()
|
repos_data = yaml.safe_load(file)
|
||||||
|
|
||||||
# Clone repositories
|
# Clone repositories
|
||||||
for repo_url in repos:
|
for repo_data in repos_data['repositories']:
|
||||||
repo_url = repo_url.strip() # Remove newline characters
|
repo_url = repo_data['url']
|
||||||
cloner.clone_repo(repo_url)
|
branch = repo_data.get('branch', 'main')
|
||||||
|
cloner.clone_repo(repo_url, branch)
|
||||||
|
Loading…
Reference in New Issue
Block a user