Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sweep: allow for rebase. #3456

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions sweepai/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from fastapi.responses import HTMLResponse
from fastapi.security import HTTPAuthorizationCredentials, HTTPBearer
from fastapi.templating import Jinja2Templates
from github import GithubException
from github.Commit import Commit
from prometheus_fastapi_instrumentator import Instrumentator

Expand Down Expand Up @@ -402,19 +403,22 @@ def update_sweep_prs_v2(repo_full_name: str, installation_id: int):
pr.edit(state="closed")
continue

repo.merge(
feature_branch,
pr.base.ref,
f"Merge main into {feature_branch}",
)
try:
repo.rebase(pr.base.ref, feature_branch)
except GithubException as e:
if e.status == 409: # Merge conflict
pr.edit(state="closed")
continue
else:
raise

# Check if the merged PR is the config PR
if pr.title == "Configure Sweep" and pr.merged:
# Create a new PR to add "gha_enabled: True" to sweep.yaml
create_gha_pr(g, repo)
except Exception as e:
logger.warning(
f"Failed to merge changes from default branch into PR #{pr.number}: {e}"
f"Failed to rebase feature branch for PR #{pr.number}: {e}"
)
except Exception:
logger.warning("Failed to update sweep PRs")
Expand Down
Loading