Skip to content

Commit

Permalink
fix: create PR tool checks out onto custom branch (#470)
Browse files Browse the repository at this point in the history
  • Loading branch information
christinewangcw authored Feb 13, 2025
1 parent 34990c8 commit b45c4f5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/codegen/extensions/langchain/tools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Langchain tools for workspace operations."""

import json
import uuid
from typing import ClassVar, Literal, Optional

from langchain.tools import BaseTool
Expand Down Expand Up @@ -355,6 +356,9 @@ def __init__(self, codebase: Codebase) -> None:
super().__init__(codebase=codebase)

def _run(self, title: str, body: str) -> str:
if self.codebase._op.git_cli.active_branch.name == self.codebase._op.default_branch:
# If the current checked out branch is the default branch, checkout onto a new branch
self.codebase.checkout(branch=f"{uuid.uuid4()}", create_if_missing=True)
pr = self.codebase.create_pr(title=title, body=body)
return pr.html_url

Expand Down

0 comments on commit b45c4f5

Please sign in to comment.