mirror of
https://github.com/qodo-ai/pr-agent.git
synced 2025-07-05 21:30:40 +08:00
Gerrit:
- support reflect/answer
This commit is contained in:
@ -197,13 +197,6 @@ class GerritProvider(GitProvider):
|
|||||||
return self.repo.branches[0].name
|
return self.repo.branches[0].name
|
||||||
|
|
||||||
def get_issue_comments(self):
|
def get_issue_comments(self):
|
||||||
# raise NotImplementedError(
|
|
||||||
# 'Getting comments is not implemented for the gerrit provider'
|
|
||||||
# )
|
|
||||||
# unclear how to get right comments from gerrit
|
|
||||||
# all user's comments like this "'Patch Set 1: (1 comment)'"
|
|
||||||
# i.e. it's not clear how to get the comment body
|
|
||||||
|
|
||||||
comments = list_comments(self.parsed_url, self.refspec)
|
comments = list_comments(self.parsed_url, self.refspec)
|
||||||
Comments = namedtuple('Comments', ['reversed'])
|
Comments = namedtuple('Comments', ['reversed'])
|
||||||
Comment = namedtuple('Comment', ['body'])
|
Comment = namedtuple('Comment', ['body'])
|
||||||
|
@ -23,12 +23,14 @@ class Action(str, Enum):
|
|||||||
describe = "describe"
|
describe = "describe"
|
||||||
ask = "ask"
|
ask = "ask"
|
||||||
improve = "improve"
|
improve = "improve"
|
||||||
|
reflect = "reflect"
|
||||||
|
answer = "answer"
|
||||||
|
|
||||||
|
|
||||||
class Item(BaseModel):
|
class Item(BaseModel):
|
||||||
refspec: str
|
refspec: str
|
||||||
project: str
|
project: str
|
||||||
msg: str = None
|
msg: str = ""
|
||||||
|
|
||||||
|
|
||||||
@router.post("/api/v1/gerrit/{action}")
|
@router.post("/api/v1/gerrit/{action}")
|
||||||
@ -36,21 +38,16 @@ async def handle_gerrit_request(action: Action, item: Item):
|
|||||||
logging.debug("Received a Gerrit request")
|
logging.debug("Received a Gerrit request")
|
||||||
context["settings"] = copy.deepcopy(global_settings)
|
context["settings"] = copy.deepcopy(global_settings)
|
||||||
|
|
||||||
agent = PRAgent()
|
if action == Action.ask:
|
||||||
pr_url = f"{item.project}:{item.refspec}"
|
|
||||||
if action == Action.review:
|
|
||||||
await agent.handle_request(pr_url, "/review")
|
|
||||||
elif action == Action.describe:
|
|
||||||
await agent.handle_request(pr_url, "/describe")
|
|
||||||
elif action == Action.improve:
|
|
||||||
await agent.handle_request(pr_url, "/improve")
|
|
||||||
elif action == Action.ask:
|
|
||||||
if not item.msg:
|
if not item.msg:
|
||||||
return HTTPException(
|
return HTTPException(
|
||||||
status_code=400,
|
status_code=400,
|
||||||
detail="msg is required for ask command"
|
detail="msg is required for ask command"
|
||||||
)
|
)
|
||||||
await agent.handle_request(pr_url, f"/ask {item.msg.strip()}")
|
await PRAgent().handle_request(
|
||||||
|
f"{item.project}:{item.refspec}",
|
||||||
|
f"/{action.value} {item.msg.strip()}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
async def get_body(request):
|
async def get_body(request):
|
||||||
|
Reference in New Issue
Block a user