|
14 | 14 | from sweepai.utils.chat_logger import ChatLogger, discord_log_error
|
15 | 15 | from sweepai.utils.diff import generate_diff
|
16 | 16 | from sweepai.utils.event_logger import posthog
|
17 |
| -from sweepai.utils.github_utils import ClonedRepo, get_github_client |
| 17 | +from sweepai.utils.github_utils import ClonedRepo, get_github_client, rebase_branch |
18 | 18 | from sweepai.utils.progress import (
|
19 | 19 | PaymentContext,
|
20 | 20 | TicketContext,
|
@@ -171,25 +171,24 @@ def edit_comment(body):
|
171 | 171 | new_pull_request.branch_name += "_" + str(i)
|
172 | 172 | break
|
173 | 173 |
|
174 |
| - # Merge into base branch from cloned_repo.repo_dir to pr.base.ref |
| 174 | + # Rebase new branch onto base branch |
175 | 175 | git_repo = cloned_repo.git_repo
|
176 | 176 | old_head_branch = git_repo.branches[branch]
|
177 | 177 | head_branch = git_repo.create_head(
|
178 | 178 | new_pull_request.branch_name,
|
179 | 179 | commit=old_head_branch.commit,
|
180 | 180 | )
|
181 | 181 | head_branch.checkout()
|
| 182 | + git_repo = rebase_branch(git_repo, new_pull_request.branch_name, pr.base.ref) |
182 | 183 | try:
|
183 | 184 | git_repo.config_writer().set_value(
|
184 | 185 | "user", "name", "sweep-nightly[bot]"
|
185 | 186 | ).release()
|
186 | 187 | git_repo.config_writer().set_value(
|
187 | 188 | "user", "email", "[email protected]"
|
188 | 189 | ).release()
|
189 |
| - git_repo.git.merge("origin/" + pr.base.ref) |
190 |
| - except GitCommandError: |
191 |
| - # Assume there are merge conflicts |
192 |
| - pass |
| 190 | + except Exception as e: |
| 191 | + print("Exception occurred while configuring git user", e) |
193 | 192 |
|
194 | 193 | git_repo.git.add(update=True)
|
195 | 194 | # -m and message are needed otherwise exception is thrown
|
|
0 commit comments