Skip to content

Commit ba9bc24

Browse files
committed
Refactor diff generation step to improve clarity and output handling
1 parent be7e9ea commit ba9bc24

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

.github/workflows/code-review.yml

+24-6
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,23 @@ jobs:
2121
# Checks out the code from the pull request's head branch.
2222
ref: ${{ github.event.pull_request.head.ref }}
2323
fetch-depth: 0
24+
25+
# Fetches the base branch (e.g., main) from the remote repository
26+
- name: Fetch base branch
27+
run: |
28+
git fetch origin ${{ github.base_ref }}
2429
25-
- name: Fetch Pull Request Branch
26-
run: git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-branch
30+
# - name: Fetch Pull Request Branch
31+
# run: git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-branch
2732

2833
- name: Generate Diff
34+
id: generate-diff
2935
run: |
30-
set -e
31-
git diff $GITHUB_BASE_REF pr-branch > change.diff
32-
echo "Diff generated successfully."
33-
echo "Diff content:" $(cat change.diff)
36+
echo "Generating diff between ${{ github.base_ref }} and ${{ github.head_ref }}"
37+
DIFF=$(git diff origin/${{ github.base_ref }}...${{ github.head_ref }})
38+
echo "diff_output<<EOF" >> $GITHUB_ENV
39+
echo "$DIFF" >> $GITHUB_ENV
40+
echo "EOF" >> $GITHUB_ENV
3441
3542
- name: Check Diff Size
3643
id: check_diff_size
@@ -43,6 +50,17 @@ jobs:
4350
exit 0
4451
fi
4552
53+
# Step 4: Output the diff (optional)
54+
- name: Print diff
55+
run: |
56+
echo "Diff Output:"
57+
echo "${{ env.diff_output }}"
58+
59+
# Step 5: Save the diff to a file (optional)
60+
- name: Save diff to file
61+
run: |
62+
echo "${{ env.diff_output }}" > changes.diff
63+
4664
# - name: Install Ollama CLI
4765
# run: |
4866
# curl -fsSL https://ollama.com/install.sh | sh

0 commit comments

Comments
 (0)