gcp-platforms-auto 0.6.3__tar.gz → 0.6.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/PKG-INFO +1 -1
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/gcp_platforms_auto/git.py +27 -8
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/gcp_platforms_auto.egg-info/PKG-INFO +1 -1
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/pyproject.toml +1 -1
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/README.md +0 -0
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/gcp_platforms_auto/__init__.py +0 -0
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/gcp_platforms_auto.egg-info/SOURCES.txt +0 -0
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/gcp_platforms_auto.egg-info/dependency_links.txt +0 -0
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/gcp_platforms_auto.egg-info/requires.txt +0 -0
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/gcp_platforms_auto.egg-info/top_level.txt +0 -0
- {gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/setup.cfg +0 -0
|
@@ -63,7 +63,7 @@ def get_repo(path_of_git_repo, branch="main", path_to_local_repo="/tmp/repo"):
|
|
|
63
63
|
raise e
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
def git_push(repo, commit_message, files_to_push=None):
|
|
66
|
+
def git_push(repo, commit_message, files_to_push=None, branch="main"):
|
|
67
67
|
try:
|
|
68
68
|
logger.info(f"Attempting to push changes to Git with commit message: '{commit_message}'")
|
|
69
69
|
if files_to_push:
|
|
@@ -74,20 +74,20 @@ def git_push(repo, commit_message, files_to_push=None):
|
|
|
74
74
|
repo.git.add(all=True)
|
|
75
75
|
logger.info(f"Committing changes with message: '{commit_message}'")
|
|
76
76
|
repo.index.commit(commit_message)
|
|
77
|
-
logger.info("Pushing changes to remote 'origin'")
|
|
78
|
-
push_info = repo.remote(name="origin").push()
|
|
77
|
+
logger.info(f"Pushing changes to remote 'origin', branch '{branch}'")
|
|
78
|
+
push_info = repo.remote(name="origin").push(refspec=f"{branch}:{branch}")
|
|
79
79
|
for info in push_info:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
if info.flags > 0:
|
|
81
|
+
logger.info(f"Git push info: {info.summary}")
|
|
82
|
+
elif info.flags == 0:
|
|
83
|
+
logger.info(f"Git push info: No update {info.summary}")
|
|
84
84
|
|
|
85
85
|
logger.info("Successfully pushed changes to Git.")
|
|
86
86
|
except Exception as e:
|
|
87
87
|
logger.exception(f"Error pushing to Git: {str(e)}")
|
|
88
88
|
raise e
|
|
89
89
|
|
|
90
|
-
def create_repo(org, repo, token, github_enterprise="github.com"):
|
|
90
|
+
def create_repo(org, repo, token, github_enterprise="github.com", branches=None):
|
|
91
91
|
try:
|
|
92
92
|
logger.info("Creating repository...")
|
|
93
93
|
is_github_cloud = github_enterprise is "github.com"
|
|
@@ -115,6 +115,25 @@ def create_repo(org, repo, token, github_enterprise="github.com"):
|
|
|
115
115
|
logger.error(f"Failed to create repository: {res.status_code} {res.text}")
|
|
116
116
|
res.raise_for_status()
|
|
117
117
|
|
|
118
|
+
if branches:
|
|
119
|
+
main_ref_url = f"{api_base}/repos/{org}/{repo}/git/refs/heads/main"
|
|
120
|
+
res = requests.get(main_ref_url, headers=headers)
|
|
121
|
+
res.raise_for_status()
|
|
122
|
+
sha = res.json()["object"]["sha"]
|
|
123
|
+
|
|
124
|
+
for br in branches:
|
|
125
|
+
if br == "main":
|
|
126
|
+
continue
|
|
127
|
+
ref_url = f"{api_base}/repos/{org}/{repo}/git/refs"
|
|
128
|
+
data = {"ref": f"refs/heads/{br}", "sha": sha}
|
|
129
|
+
r = requests.post(ref_url, headers=headers, json=data)
|
|
130
|
+
if r.status_code == 201:
|
|
131
|
+
logger.info(f"Created branch {br}")
|
|
132
|
+
elif r.status_code == 422 and "Reference already exists" in r.text:
|
|
133
|
+
logger.warning(f"Branch {br} already exists, skipping")
|
|
134
|
+
else:
|
|
135
|
+
logger.error(f"Failed to create branch {br}: {r.status_code} {r.text}")
|
|
136
|
+
|
|
118
137
|
except Exception as e:
|
|
119
138
|
logger.exception(f"Error creating repository: {str(e)}")
|
|
120
139
|
raise e
|
|
File without changes
|
|
File without changes
|
{gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/gcp_platforms_auto.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/gcp_platforms_auto.egg-info/requires.txt
RENAMED
|
File without changes
|
{gcp_platforms_auto-0.6.3 → gcp_platforms_auto-0.6.5}/gcp_platforms_auto.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|