File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
src/codegen/runner/servers Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -79,10 +79,21 @@ async def run(request: RunFunctionRequest) -> CodemodRunResult:
79
79
diff_req = GetDiffRequest (codemod = Codemod (user_code = request .codemod_source ))
80
80
diff_response = await runner .get_diff (request = diff_req )
81
81
if request .commit :
82
- changed_files = runner .op .get_modified_files (runner .commit )
83
- # if the only changed file is the function that was requested, do not commit
84
- if len (changed_files ) == 1 and os .path .splitext (os .path .basename (changed_files [0 ])) == request .function_name :
82
+ if _should_skip_commit (request .function_name ):
85
83
logger .info (f"Skipping commit because only changes to { request .function_name } were made" )
86
84
elif commit_sha := runner .codebase .git_commit (f"[Codegen] { request .function_name } " ):
87
85
logger .info (f"Committed changes to { commit_sha .hexsha } " )
88
86
return diff_response .result
87
+
88
+
89
+ def _should_skip_commit (function_name : str ) -> bool :
90
+ changed_files = runner .op .get_modified_files (runner .commit )
91
+ if len (changed_files ) != 1 :
92
+ return False
93
+
94
+ file_path = changed_files [0 ]
95
+ if not file_path .startswith (".codegen/codemods/" ):
96
+ return False
97
+
98
+ changed_file_name = os .path .splitext (os .path .basename (file_path ))[0 ]
99
+ return changed_file_name == function_name .replace ("-" , "_" )
You can’t perform that action at this time.
0 commit comments