Skip to content

update github action to log git diff in output #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rajsinghparihar
Copy link
Member

No description provided.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Bug Found in Code

Potential Issues and Errors:

  • The code changes may cause issues with the Git diff functionality, potentially leading to incorrect or incomplete diff results.
  • The introduction of a new environment variable DEFAULT_BRANCH may cause conflicts or unexpected behavior if not properly handled.
  • The exclusion of PNG files from the diff may not be intended or may have unintended consequences on the code review process.

Most Important Findings:

  • The code has been modified to fetch the default branch instead of the pull request head ref, which may alter the diff results (lines 18-20).
  • The git diff command has been updated to exclude PNG files, which may not be the intended behavior (line 21).
  • The way the diff result is stored in an environment variable has been changed, using a multi-line string approach (lines 23-26).

Code Block and Line Numbers:

@@ -18,13 +18,20 @@ jobs:
         id: get_diff
         shell: bash
         env:
+          DEFAULT_BRANCH: "${{ github.event.repository.default_branch }}"
           PULL_REQUEST_HEAD_REF: "${{ github.event.pull_request.head.ref }}"
         run: |-
-          git fetch origin "${{ env.PULL_REQUEST_HEAD_REF }}:${{ env.PULL_REQUEST_HEAD_REF }}"
-          git checkout "${{ env.PULL_REQUEST_HEAD_REF }}"
-          git diff "origin/${{ env.PULL_REQUEST_HEAD_REF }}" > "diff.txt"
+          # Fetch the default branch
+          git fetch origin "${{ env.DEFAULT_BRANCH }}"
+          # Exclude png files from diff
+          git diff "origin/${{ env.DEFAULT_BRANCH }}" ":(exclude)*.png" > "diff.txt"
+          # Put multi-line string into an environment variable
           # shellcheck disable=SC2086
-          echo "diff=$(cat "diff.txt")" >> $GITHUB_ENV
+          {
+            echo "pull_request_diff<<EOF";
+            cat "diff.txt";
+            echo 'EOF';
+          } >> $GITHUB_OUTPUT

Lines 18-26 have been modified, introducing changes to the Git diff functionality and environment variable handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant