Skip to content
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

pre-commit handling #394

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

Conversation

mpoberezhniy
Copy link
Contributor

Issue: #234

Testing: I created a tag in my fork and used the following yaml for pre-commit testing.

$ cat .pre-commit-config.yaml 
repos:
-   repo: https://github.com/mpoberezhniy/differential-shellcheck
    rev: v0.0.1
    hooks:
    -   id: differential-shellcheck

$ pre-commit run
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to ~/.cache/pre-commit/patch1714424233-141350.
Differential ShellCheck..................................................Failed
- hook id: differential-shellcheck
- duration: 0.6s
- exit code: 1

:::::::::::::::::::::
::: Used Versions :::
:::::::::::::::::::::

ShellCheck: 0.9.0
csutils: 3.2.1


:::::::::::::::::::::::::::::::
::: Differential ShellCheck :::
:::::::::::::::::::::::::::::::

📜 List of shell scripts for scanning
test.sh

ℹ️ No Fixes!

📊 Statistics of defects
Error: 0
Warning: 1
Style or Note: 1


✋ Defects, NEEDS INSPECTION
Error: SHELLCHECK_WARNING:
test.sh:2:6: warning[SC2048]: Use "$@" (with quotes) to prevent whitespace problems.
#    1|   #!/bin/sh
#    2|-> echo $*

Error: SHELLCHECK_WARNING:
test.sh:2:6: info[SC2086]: Double quote to prevent globbing and word splitting.
#    1|   #!/bin/sh
#    2|-> echo $*
### Differential ShellCheck 🐚

Scanned/Changed scripts: `1`

|                    | ❌ Added                 | ✅ Fixed                 |
|:------------------:|:------------------------:|:------------------------:|
| ⚠️ Errors / Warnings / Notes |  **2**  |  **0**  |

#### New defects statistics

|          | 👕 Style / 🗒️ Note      | ⚠️ Warning                 | 🛑 Error                 |
|:--------:|:-----------------------:|:--------------------------:|:------------------------:|
| 🔢 Count | **1** | **1** | **0** |

#### Useful links

- [Differential ShellCheck Documentation](https://github.com/redhat-plumbers-in-action/differential-shellcheck#readme)
- [ShellCheck Documentation](https://github.com/koalaman/shellcheck#readme)

---
_ℹ️ If you have an issue with this GitHub action, please try to run it in the [debug mode](https://github.blog/changelog/2022-05-24-github-actions-re-run-jobs-with-debug-logging/) and submit an [issue](https://github.com/redhat-plumbers-in-action/differential-shellcheck/issues/new)._

[INFO] Restored changes from ~/.cache/pre-commit/patch1714424233-141350.

TODO:

  • Rework summary format to look nice when running from both actions and pre-commit
  • Tests

@mergify mergify bot added the source label Apr 29, 2024
src/pre-commit.sh Fixed Show fixed Hide fixed
esac
done

SCRIPT_DIR="$(dirname "$(readlink -f "$0")")/"

Check warning

Code scanning / shellcheck

Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore). Warning

Consider invoking this command separately to avoid masking its return value (or use '|| true' to ignore).
src/pre-commit.sh Fixed Show fixed Hide fixed
src/pre-commit.sh Fixed Show fixed Hide fixed
src/pre-commit.sh Fixed Show fixed Hide fixed
src/pre-commit.sh Fixed Show fixed Hide fixed
src/pre-commit.sh Fixed Show fixed Hide fixed
@codecov-commenter
Copy link

codecov-commenter commented Apr 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.17%. Comparing base (8f0e0a6) to head (6fa4c10).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #394      +/-   ##
==========================================
+ Coverage   84.96%   85.17%   +0.20%     
==========================================
  Files           4        4              
  Lines         286      290       +4     
==========================================
+ Hits          243      247       +4     
  Misses         43       43              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

- id: differential-shellcheck
name: Differential ShellCheck
description: Static analysis tool for changed shell scripts
language: docker
Copy link
Contributor Author

@mpoberezhniy mpoberezhniy Apr 29, 2024

Choose a reason for hiding this comment

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

This is temporary, docker_image should be used when ready.

@jamacku jamacku added the type: feature New feature label Apr 30, 2024
@jamacku jamacku linked an issue May 1, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider adding support for pre-commit hook ⚓
3 participants