Skip to content

Commit 85defbd

Browse files
author
juancarlos.cavero
committed
Fix push-git: force checkout main branch, handle dirty git state
1 parent b701280 commit 85defbd

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

platform-api/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,18 +618,18 @@ def _git(*args):
618618
# Fix ownership issue (agent creates files as uid 1000, platform-api runs as root)
619619
_git("config", "--global", "--add", "safe.directory", workspace)
620620

621-
# Init if needed
621+
# Always ensure clean git state
622622
if not os.path.exists(os.path.join(workspace, ".git")):
623623
_git("init")
624-
_git("branch", "-M", "main")
624+
_git("checkout", "-B", "main") # Create/switch to main branch
625625

626626
# Set remote
627627
_git("remote", "remove", "origin")
628628
_git("remote", "add", "origin", clone_url)
629629

630-
# Add, commit, push
630+
# Add all files, commit, push
631631
_git("add", "-A")
632-
commit_result = _git("commit", "-m", body.message, "--allow-empty")
632+
_git("commit", "-m", body.message, "--allow-empty")
633633
push_result = _git("push", "-u", "origin", "main")
634634

635635
if push_result.returncode != 0:

0 commit comments

Comments
 (0)