| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 3bb300d commit 01c8875
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -54,13 +54,8 @@ def do_backport( | |||
| 54 | 54 | logger.debug(f"Hunk {idx} can be applied without any conflicts") | |
| 55 | 55 | continue | |
| 56 | 56 | else: | |
| 57 | - try: | ||
| 58 | - similar_block = re.findall( | ||
| 59 | - r"version.\n(.*?)\nBesides,", ret, re.DOTALL | ||
| 60 | - )[0] | ||
| 61 | - except: | ||
| 62 | - similar_block = "Something error in finding similar block\n" + ret | ||
| 63 | - logger.warning("Something error in finding similar block") | ||
| 57 | + block_list = re.findall(r"older version.\n(.*?)\nBesides,", ret, re.DOTALL) | ||
| 58 | + similar_block = "\n".join(block_list) | ||
| 64 | 59 | logger.debug(f"Hunk {idx} can not be applied, using LLM to generate a fix") | |
| 65 | 60 | agent_executor.invoke( | |
| 66 | 61 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -212,7 +212,8 @@ def _apply_file_move_handling(self, ref: str, old_patch: str) -> str: | |||
| 212 | 212 | # XXX: find symbol: the word before the first '{' or '(' | |
| 213 | 213 | # @@ -135,7 +135,6 @@ struct ksmbd_transport_ops { | |
| 214 | 214 | # @@ -416,13 +416,7 @@ static void stop_sessions(void) | |
| 215 | - symbol_name = re.findall(r"\b\w+(?=\s*[{\(])", old_patch)[0] | ||
| 215 | + at_line = old_patch.split("\n")[2] | ||
| 216 | + symbol_name = re.findall(r"\b\w+(?=\s*[{\(])", at_line)[0] | ||
| 216 | 217 | symbol_locations = self._locate_symbol(ref, symbol_name) | |
| 217 | 218 | if not symbol_locations: | |
| 218 | 219 | logger.debug( | |
@@ -231,22 +232,19 @@ def _apply_file_move_handling(self, ref: str, old_patch: str) -> str: | |||
| 231 | 232 | ) | |
| 232 | 233 | ||
| 233 | 234 | # try to apply patch to the target files | |
| 234 | - find_file = False | ||
| 235 | 235 | for file_path in file_paths: | |
| 236 | 236 | new_patch = old_patch.replace(missing_file_path, file_path) | |
| 237 | 237 | logger.debug(f"Try to apply patch to {file_path}.") | |
| 238 | - if "successfully" in self._apply_hunk(ref, new_patch, False): | ||
| 239 | - find_file = True | ||
| 238 | + apply_ret = self._apply_hunk(ref, new_patch, False) | ||
| 239 | + if "successfully" in apply_ret: | ||
| 240 | 240 | logger.debug(f"{missing_file_path} has been moved to {file_path}.") | |
| 241 | - ret += f"{missing_file_path} has been moved to {file_path}. Please use --- a/{file_path} in your patch.\n" | ||
| 242 | - break | ||
| 241 | + return f"{missing_file_path} has been moved to {file_path}. Please use --- a/{file_path} in your patch.\n" | ||
| 242 | + else: | ||
| 243 | + ret += apply_ret | ||
| 243 | 244 | ||
| 244 | 245 | # patch can not apply directly | |
| 245 | - if not find_file: | ||
| 246 | - logger.debug(f"Patch can not be applied to {file_paths}.") | ||
| 247 | - # find symbol, but patch can not apply directly | ||
| 248 | - return f"The target file has been moved, here is possible file paths:{file_paths}\n" | ||
| 249 | - return ret | ||
| 246 | + logger.debug(f"Patch can not be applied to {file_paths}.") | ||
| 247 | + return f"The target file has been moved, here is possible file paths:{file_paths}\n{ret}" | ||
| 250 | 248 | ||
| 251 | 249 | def _apply_hunk(self, ref: str, patch: str, revise_context: bool = False) -> str: | |
| 252 | 250 | """ | |
| Back | FazBrowse Home | New Git URL |
0 commit comments