Skip to content

Commit 3920d4b

Browse files
mouredev#43 - GitCLI - José Lorente López
1 parent f477df1 commit 3920d4b

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Roadmap/43 - GIT GITHUB CLI/python/joselorentelopez.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,29 +166,26 @@ def pull_changes(): # recommended pre push
166166

167167
@staticmethod
168168
def push_changes():
169-
# Verificar si hay commits en el repositorio
169+
170170
result = subprocess.run(["git", "rev-parse", "--is-inside-work-tree"], capture_output=True, text=True)
171171

172172
if result.returncode != 0:
173173
print("Not a valid Git repository. Please ensure you are in a valid Git directory.")
174174
return
175175

176-
# Obtener el nombre de la rama actual
177176
result = subprocess.run(["git", "branch", "--show-current"], capture_output=True, text=True)
178177
current_branch = result.stdout.strip()
179178

180179
if not current_branch:
181180
print("No branch detected. Please ensure you have a branch checked out before pushing.")
182181
return
183182

184-
# Asegurarse de que la rama actual tiene commits
185183
commit_result = subprocess.run(["git", "rev-parse", current_branch], capture_output=True, text=True)
186184

187185
if commit_result.returncode != 0:
188186
print(f"The branch '{current_branch}' has no commits. Please make an initial commit before pushing.")
189187
return
190188

191-
# Realizar el push de la rama actual
192189
try:
193190
subprocess.run(["git", "push", "-u", "origin", current_branch], check=True)
194191
print(f"Changes pushed successfully to branch '{current_branch}'.\n")

0 commit comments

Comments
 (0)