2
2
import logging
3
3
import os
4
4
from shutil import rmtree
5
+ from pathlib import Path
5
6
import subprocess
6
7
import sys
7
- import time
8
8
import traceback
9
9
from typing import Optional
10
10
@@ -174,13 +174,14 @@ async def run_with_schema(self, input: TInputSchema) -> TOutputSchema:
174
174
175
175
176
176
def prepare_package (package : str , jira_issue : str , dist_git_branch : str ,
177
- input_schema : InputSchema ) -> tuple [str , str ]:
177
+ input_schema : InputSchema ) -> tuple [Path , Path ]:
178
178
"""
179
179
Prepare the package for backporting by cloning the dist-git repository, switching to the appropriate branch,
180
180
and downloading the sources.
181
181
Returns the path to the unpacked sources.
182
182
"""
183
- os .makedirs (input_schema .git_repo_basepath , exist_ok = True )
183
+ git_repo = Path (input_schema .git_repo_basepath )
184
+ git_repo .mkdir (parents = True , exist_ok = True )
184
185
subprocess .check_call (
185
186
[
186
187
"centpkg" ,
@@ -190,9 +191,9 @@ def prepare_package(package: str, jira_issue: str, dist_git_branch: str,
190
191
dist_git_branch ,
191
192
package ,
192
193
],
193
- cwd = input_schema . git_repo_basepath ,
194
+ cwd = git_repo ,
194
195
)
195
- local_clone = os . path . join ( input_schema . git_repo_basepath , package )
196
+ local_clone = git_repo / package
196
197
subprocess .check_call (
197
198
[
198
199
"git" ,
@@ -205,9 +206,7 @@ def prepare_package(package: str, jira_issue: str, dist_git_branch: str,
205
206
)
206
207
subprocess .check_call (["centpkg" , "sources" ], cwd = local_clone )
207
208
subprocess .check_call (["centpkg" , "prep" ], cwd = local_clone )
208
- unpacked_sources = glob .glob (
209
- os .path .join (local_clone , "*-build" , f"*{ package } *" )
210
- )
209
+ unpacked_sources = list (local_clone .glob (f"*-build/*{ package } *" ))
211
210
if len (unpacked_sources ) != 1 :
212
211
raise ValueError (
213
212
f"Expected exactly one unpacked source, got { unpacked_sources } "
@@ -234,7 +233,8 @@ async def main() -> None:
234
233
jira_issue = jira_issue ,
235
234
dist_git_branch = branch ,
236
235
)
237
- input .unpacked_sources , local_clone = prepare_package (package , jira_issue , branch , input )
236
+ unpacked_sources , local_clone = prepare_package (package , jira_issue , branch , input )
237
+ input .unpacked_sources = str (unpacked_sources )
238
238
try :
239
239
output = await agent .run_with_schema (input )
240
240
finally :
0 commit comments