Skip to content

Commit 535fd48

Browse files
authored
chore: convert function name to underscores (#693)
1 parent 96c1c98 commit 535fd48

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/codegen/runner/servers/local_daemon.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,21 @@ async def run(request: RunFunctionRequest) -> CodemodRunResult:
7979
diff_req = GetDiffRequest(codemod=Codemod(user_code=request.codemod_source))
8080
diff_response = await runner.get_diff(request=diff_req)
8181
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):
8583
logger.info(f"Skipping commit because only changes to {request.function_name} were made")
8684
elif commit_sha := runner.codebase.git_commit(f"[Codegen] {request.function_name}"):
8785
logger.info(f"Committed changes to {commit_sha.hexsha}")
8886
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("-", "_")

0 commit comments

Comments
 (0)