f
This commit is contained in:
parent
09515c196c
commit
26cb198bad
3 changed files with 65 additions and 7 deletions
|
|
@ -49,7 +49,7 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Login to Forgejo Registry
|
||||
uses: docker/login-action@v3
|
||||
|
|
|
|||
|
|
@ -292,9 +292,16 @@ class AgentOrchestrator:
|
|||
if not self._git_commit(commit_message):
|
||||
print("⚠️ No changes to commit")
|
||||
|
||||
# Push changes
|
||||
# Push changes (with pull before push to avoid conflicts)
|
||||
print("\n📤 Pushing changes...")
|
||||
self._git_push()
|
||||
if not self._git_push():
|
||||
print("⚠️ Push failed, pulling latest changes and retrying...")
|
||||
# Pull latest changes before retrying push
|
||||
if self._git_pull():
|
||||
print("✅ Pulled latest changes, retrying push...")
|
||||
self._git_push()
|
||||
else:
|
||||
print("❌ Failed to pull latest changes")
|
||||
|
||||
return True
|
||||
|
||||
|
|
@ -482,7 +489,36 @@ Changes:
|
|||
return False
|
||||
|
||||
def _git_push(self) -> bool:
|
||||
"""Push changes to remote."""
|
||||
"""Push changes to remote. Pulls first if needed to avoid conflicts."""
|
||||
# First, fetch to check if there are remote changes
|
||||
fetch_result = subprocess.run(
|
||||
["git", "fetch"],
|
||||
cwd=self.config.project_root,
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
if fetch_result.returncode != 0:
|
||||
print(f"⚠️ Failed to fetch: {fetch_result.stderr}")
|
||||
# Continue anyway, might be network issue
|
||||
|
||||
# Check if local branch is behind remote
|
||||
check_result = subprocess.run(
|
||||
["git", "rev-list", "--count", "HEAD..origin/master"],
|
||||
cwd=self.config.project_root,
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
if check_result.returncode == 0:
|
||||
behind_count = check_result.stdout.strip()
|
||||
if behind_count and int(behind_count) > 0:
|
||||
print(f"⚠️ Local branch is {behind_count} commit(s) behind remote")
|
||||
print(" Pulling latest changes before push...")
|
||||
if not self._git_pull():
|
||||
print("❌ Failed to pull, push may fail")
|
||||
|
||||
# Now try to push
|
||||
result = subprocess.run(
|
||||
["git", "push"],
|
||||
cwd=self.config.project_root,
|
||||
|
|
@ -494,8 +530,30 @@ Changes:
|
|||
print("✅ Pushed to remote")
|
||||
return True
|
||||
else:
|
||||
print(f"⚠️ Push failed: {result.stderr}")
|
||||
return False
|
||||
# If push failed due to remote changes, try pull and push again
|
||||
if "fetch first" in result.stderr or "Updates were rejected" in result.stderr:
|
||||
print("⚠️ Push rejected due to remote changes")
|
||||
print(" Pulling and retrying push...")
|
||||
if self._git_pull():
|
||||
# Retry push after pull
|
||||
retry_result = subprocess.run(
|
||||
["git", "push"],
|
||||
cwd=self.config.project_root,
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
if retry_result.returncode == 0:
|
||||
print("✅ Pushed to remote after pull")
|
||||
return True
|
||||
else:
|
||||
print(f"❌ Push failed after pull: {retry_result.stderr}")
|
||||
return False
|
||||
else:
|
||||
print("❌ Failed to pull before retry")
|
||||
return False
|
||||
else:
|
||||
print(f"⚠️ Push failed: {result.stderr}")
|
||||
return False
|
||||
|
||||
def _create_issue_for_failed_task(self, task: Task) -> None:
|
||||
"""Create GitHub/Forgejo issue for failed task."""
|
||||
|
|
|
|||
Loading…
Reference in a new issue