From 4b957ae13d61f1de71ca5185f85e2debcb716464 Mon Sep 17 00:00:00 2001 From: mschwoerer <82171591+mschwoer@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:44:41 +0200 Subject: [PATCH] first draft --- .github/workflows/code_review.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/code_review.yml b/.github/workflows/code_review.yml index b164c331..295a9caa 100644 --- a/.github/workflows/code_review.yml +++ b/.github/workflows/code_review.yml @@ -45,16 +45,24 @@ jobs: except subprocess.CalledProcessError: return "" # Return empty string if file doesn't exist in that ref + def get_file_patch(file_path): + try: + return subprocess.check_output(['git', 'diff', 'HEAD^', 'HEAD', '--', file_path], text=True) + except subprocess.CalledProcessError: + return "" + changed_files = '${{ steps.changed-files.outputs.all_changed_files }}'.split() file_data = [] for file in changed_files: original_content = get_file_content(file, 'HEAD^') changed_content = get_file_content(file, 'HEAD') + patch = get_file_patch(file) file_data.append({ "filename": file, "originalContent": original_content, - "changedContent": changed_content + "changedContent": changed_content, + "patch": patch }) print("XXX", changed_files)