Skip to content

pre-commit handling - #394

Draft
mpoberezhniy wants to merge 1 commit into
redhat-plumbers-in-action:mainfrom
mpoberezhniy:pre-commit
Draft

mpoberezhniy wants to merge 1 commit into
redhat-plumbers-in-action:mainfrom
mpoberezhniy:pre-commit

Conversation

@mpoberezhniy

Copy link
Copy Markdown
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
Comment thread src/pre-commit.sh Fixed
Comment thread src/pre-commit.sh
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).

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

codecov-commenter commented Apr 29, 2024 •

Copy link
Copy Markdown

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.

Comment thread .pre-commit-hooks.yaml
- id: differential-shellcheck
name: Differential ShellCheck
description: Static analysis tool for changed shell scripts
language: docker

@mpoberezhniy mpoberezhniy Apr 29, 2024 •

Copy link
Copy Markdown
Contributor Author

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

This branch has not been deployed

No deployments
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 ⚓

4 participants