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:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Login to Forgejo Registry
|
- name: Login to Forgejo Registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
|
|
||||||
|
|
@ -292,9 +292,16 @@ class AgentOrchestrator:
|
||||||
if not self._git_commit(commit_message):
|
if not self._git_commit(commit_message):
|
||||||
print("⚠️ No changes to commit")
|
print("⚠️ No changes to commit")
|
||||||
|
|
||||||
# Push changes
|
# Push changes (with pull before push to avoid conflicts)
|
||||||
print("\n📤 Pushing changes...")
|
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
|
return True
|
||||||
|
|
||||||
|
|
@ -482,7 +489,36 @@ Changes:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _git_push(self) -> bool:
|
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(
|
result = subprocess.run(
|
||||||
["git", "push"],
|
["git", "push"],
|
||||||
cwd=self.config.project_root,
|
cwd=self.config.project_root,
|
||||||
|
|
@ -494,8 +530,30 @@ Changes:
|
||||||
print("✅ Pushed to remote")
|
print("✅ Pushed to remote")
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print(f"⚠️ Push failed: {result.stderr}")
|
# If push failed due to remote changes, try pull and push again
|
||||||
return False
|
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:
|
def _create_issue_for_failed_task(self, task: Task) -> None:
|
||||||
"""Create GitHub/Forgejo issue for failed task."""
|
"""Create GitHub/Forgejo issue for failed task."""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue