Skip to content

Commit

Permalink
Issue checkstyle#15837: print diff as patch
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitsatr authored and romani committed Nov 9, 2024
1 parent b167797 commit c42a764
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
20 changes: 20 additions & 0 deletions .ci/print-diff-as-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -e

if [ -z "$1" ]; then
echo "patch file-path not provided"
echo "Usage: $0 <output_file_path>"
exit 1
fi

patch_file="$1"
echo "git diff > $patch_file"
git diff > "$patch_file"

echo 'If you are ok with diff of this run,'
echo 'you will need to run the following entire multiline command:'
echo "patch -p1 <<'EOF'"
cat "$patch_file"
echo "EOF"

exit 1
2 changes: 1 addition & 1 deletion .github/workflows/checker-framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

- name: Git Diff on fail
if: failure()
run: git diff && git diff > target/checker-${{ matrix.profile }}.patch
run: ./.ci/print-diff-as-patch.sh target/checker-${{ matrix.profile }}.patch

- name: Share patch as artifact to apply on local
if: failure()
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/pitest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,12 @@ jobs:
- name: Patch command for pitest-${{ matrix.profile }}
if: failure()
run: |
printf "\nTo patch suppression list run:\n\n"
GIT_DIFF=$(git diff)
printf "patch -p1 << EOF\n%s\nEOF" "$GIT_DIFF"
exit 1
./.ci/print-diff-as-patch.sh target/pitest-${{ matrix.profile }}.patch
- name: Stage results
if: failure() || github.ref == 'refs/heads/master'
run: |
mkdir staging && cp -r target/pit-reports/ staging
git diff && git diff > target/pitest-${{ matrix.profile }}.patch
- name: Archive code coverage results
if: failure() || github.ref == 'refs/heads/master'
Expand Down

0 comments on commit c42a764

Please sign in to comment.