25
25
26
26
from tools .specfile import AddChangelogEntryTool , BumpReleaseTool
27
27
from tools .text import CreateTool , InsertTool , StrReplaceTool , ViewTool
28
- from tools .wicked_git import GitPatchCreationTool
28
+ from tools .wicked_git import GitLogSearchTool , GitPatchCreationTool
29
29
from constants import COMMIT_PREFIX , BRANCH_PREFIX
30
30
from observability import setup_observability
31
31
from tools .commands import RunShellCommandTool
@@ -39,6 +39,7 @@ class InputSchema(BaseModel):
39
39
package : str = Field (description = "Package to update" )
40
40
upstream_fix : str = Field (description = "Link to an upstream fix for the issue" )
41
41
jira_issue : str = Field (description = "Jira issue to reference as resolved" )
42
+ cve_id : str = Field (default = "" , description = "CVE ID if the jira issue is a CVE" )
42
43
dist_git_branch : str = Field (description = "Git branch in dist-git to be updated" )
43
44
git_repo_basepath : str = Field (
44
45
description = "Base path for cloned git repos" ,
@@ -60,6 +61,8 @@ class OutputSchema(BaseModel):
60
61
def render_prompt (input : InputSchema ) -> str :
61
62
template = (
62
63
'Work inside the repository cloned at "{{ git_repo_basepath }}/{{ package }}"\n '
64
+ "Use the `git_log_search` tool to check if the jira issue ({{ jira_issue }}) or CVE ({{ cve_id }}) is already resolved.\n "
65
+ "If the issue or the cve are already resolved, exit the backporting process with success=True and status=\" Backport already applied\" \n "
63
66
"Download the upstream fix from {{ upstream_fix }}\n "
64
67
'Store the patch file as "{{ jira_issue }}.patch" in the repository root\n '
65
68
"If directory {{ unpacked_sources }} is not a git repository, run `git init` in it "
@@ -83,7 +86,6 @@ def backport_git_steps(data):
83
86
commit_title = f"{ COMMIT_PREFIX } backport { input_data .jira_issue } " ,
84
87
files_to_commit = f"*.spec and { input_data .jira_issue } .patch" ,
85
88
branch_name = f"{ BRANCH_PREFIX } -{ input_data .jira_issue } " ,
86
- git_url = input_data .git_url ,
87
89
dist_git_branch = input_data .dist_git_branch ,
88
90
)
89
91
@@ -136,6 +138,7 @@ async def main() -> None:
136
138
logging .basicConfig (level = logging .INFO )
137
139
138
140
setup_observability (os .getenv ("COLLECTOR_ENDPOINT" ))
141
+ cve_id = os .getenv ("CVE_ID" , "" )
139
142
140
143
async with mcp_tools (os .getenv ("MCP_GATEWAY_URL" )) as gateway_tools :
141
144
agent = RequirementAgent (
@@ -149,6 +152,7 @@ async def main() -> None:
149
152
InsertTool (),
150
153
StrReplaceTool (),
151
154
GitPatchCreationTool (),
155
+ GitLogSearchTool (),
152
156
BumpReleaseTool (),
153
157
AddChangelogEntryTool (),
154
158
]
@@ -200,6 +204,7 @@ async def run(input):
200
204
upstream_fix = upstream_fix ,
201
205
jira_issue = jira_issue ,
202
206
dist_git_branch = branch ,
207
+ cve_id = cve_id ,
203
208
)
204
209
unpacked_sources , local_clone = prepare_package (package , jira_issue , branch , input )
205
210
input .unpacked_sources = str (unpacked_sources )
@@ -245,6 +250,7 @@ class Task(BaseModel):
245
250
upstream_fix = backport_data .patch_url ,
246
251
jira_issue = backport_data .jira_issue ,
247
252
dist_git_branch = backport_data .branch ,
253
+ cve_id = backport_data .cve_id ,
248
254
)
249
255
input .unpacked_sources , local_clone = prepare_package (
250
256
backport_data .package , backport_data .jira_issue , backport_data .branch , input
0 commit comments