priv-kweihmann / systemdlint

Systemd Linter
BSD 2-Clause "Simplified" License
32 stars 6 forks source link

pre-commit support #75

Open lwbt opened 12 hours ago

lwbt commented 12 hours ago

Please consider exiting with a different status than 0 when issues have been found. This would make it easier to use systemdlint for things like the https://pre-commit.com/ framework.

At the moment, instead of just calling the program, I have to do some ugly scripting:

repos:
  - repo: local
    hooks:
      - id: systemdlint
        name: Systemd Unit Lint
        #entry: systemdlint
        entry: bash -c 'OUTPUT=$(systemdlint "$@" 2>&1); EXIT_CODE=$?; echo "$OUTPUT"; if [[ -n "$(echo "$OUTPUT" | grep -v "^$")" ]]; then exit 1; else exit 0; fi' --
        language: system
        files: \.(service|socket|device|mount|automount|swap|target|path|timer|slice|scope)$
        require_serial: true

An official pre-commit hook would also be nice by the way, may be you find this example helpful: https://github.com/scop/pre-commit-shfmt/blob/main/.pre-commit-hooks.yaml

priv-kweihmann commented 3 hours ago

Partial duplicate of #73 - but pre-commit support might be a good idea for a 2.0