diff options
author | Sorin Sbarnea <ssbarnea@redhat.com> | 2020-01-07 20:46:18 +0000 |
---|---|---|
committer | Sorin Sbarnea <ssbarnea@redhat.com> | 2020-01-14 13:42:59 +0000 |
commit | e9cd3319cf14b3d9484c4e6d7aa5040509a81653 (patch) | |
tree | 522210d5972a9de60223b062a68d4770debb232b | |
parent | 6c3d383b50439058c57b9f3235643aaf168d3148 (diff) | |
download | podman-e9cd3319cf14b3d9484c4e6d7aa5040509a81653.tar.gz podman-e9cd3319cf14b3d9484c4e6d7aa5040509a81653.tar.bz2 podman-e9cd3319cf14b3d9484c4e6d7aa5040509a81653.zip |
Enable pre-commit tool linting
This should help use keep the codebase more consistent, and avoid sevel
whitespace related issues, or bad file permissions.
pre-commit allows us to easily introduce other linters in follow-ups,
like bashate.
Note: pre-commit tool does *not* install any git-hooks. Making commits
will will call the tool unless you deliverately tell it to install the
hooks.
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
-rw-r--r-- | .pre-commit-config.yaml | 12 | ||||
-rw-r--r--[-rwxr-xr-x] | API.md | 0 | ||||
-rw-r--r-- | Makefile | 9 | ||||
-rw-r--r-- | contrib/gate/Dockerfile | 1 | ||||
-rw-r--r-- | contrib/snapcraft/.editorconfig | 2 | ||||
-rw-r--r-- | docs/source/Commands.rst | 2 | ||||
-rw-r--r-- | docs/source/network.rst | 2 | ||||
-rw-r--r-- | docs/source/volume.rst | 2 | ||||
-rw-r--r-- | test/install/.gitignore | 2 | ||||
-rw-r--r-- | test/install/README.md | 2 | ||||
-rw-r--r-- | test/trust_set_test.json | 2 |
11 files changed, 28 insertions, 8 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..4de8e4c12 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,12 @@ +--- +exclude: ^vendor/ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks.git + rev: v2.4.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - id: mixed-line-ending + - id: check-byte-order-marker + - id: check-executables-have-shebangs + - id: check-merge-conflict @@ -32,8 +32,10 @@ BUILDTAGS ?= \ exclude_graphdriver_devicemapper \ seccomp \ varlink -PYTHON ?= $(shell command -v python python3|head -n1) +PYTHON ?= $(shell command -v python3 python|head -n1) PKG_MANAGER ?= $(shell command -v dnf yum|head -n1) +# ~/.local/bin is not in PATH on all systems +PRE_COMMIT = $(shell command -v bin/venv/bin/pre-commit ~/.local/bin/pre-commit pre-commit | head -n1) SOURCES = $(shell find . -name "*.go") @@ -149,6 +151,11 @@ endif touch $@ lint: golangci-lint +ifeq ($(PRE_COMMIT),) + @echo "FATAL: pre-commit was not found, check https://pre-commit.com/ about installing it." >&2 + @exit 2 +endif + $(PRE_COMMIT) run -a golangci-lint: .gopathok varlink_generate .install.golangci-lint $(GOBIN)/golangci-lint run --tests=false --skip-files swagger.go diff --git a/contrib/gate/Dockerfile b/contrib/gate/Dockerfile index 1939d7ad1..d1e0b967b 100644 --- a/contrib/gate/Dockerfile +++ b/contrib/gate/Dockerfile @@ -48,6 +48,7 @@ WORKDIR $GOSRC RUN set -x && \ make install.tools && \ install -D -m 755 $GOSRC/contrib/gate/entrypoint.sh /usr/local/bin/ && \ + python3 -m pip install pre-commit && \ rm -rf "$GOSRC" # Install cni config diff --git a/contrib/snapcraft/.editorconfig b/contrib/snapcraft/.editorconfig index 1749b2d4c..89bc6dc80 100644 --- a/contrib/snapcraft/.editorconfig +++ b/contrib/snapcraft/.editorconfig @@ -14,4 +14,4 @@ indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true -insert_final_newline = true
\ No newline at end of file +insert_final_newline = true diff --git a/docs/source/Commands.rst b/docs/source/Commands.rst index 276a9c4fb..028f03429 100644 --- a/docs/source/Commands.rst +++ b/docs/source/Commands.rst @@ -104,4 +104,4 @@ Commands :doc:`volume <volume>` Manage volumes -:doc:`wait <markdown/podman-wait.1>` Block on one or more containers
\ No newline at end of file +:doc:`wait <markdown/podman-wait.1>` Block on one or more containers diff --git a/docs/source/network.rst b/docs/source/network.rst index c1c53bc34..d96e00a7d 100644 --- a/docs/source/network.rst +++ b/docs/source/network.rst @@ -7,4 +7,4 @@ Network :doc:`ls <markdown/podman-network-ls.1>` network list -:doc:`rm <markdown/podman-network-rm.1>` network rm
\ No newline at end of file +:doc:`rm <markdown/podman-network-rm.1>` network rm diff --git a/docs/source/volume.rst b/docs/source/volume.rst index 43fe87054..a966feafd 100644 --- a/docs/source/volume.rst +++ b/docs/source/volume.rst @@ -8,4 +8,4 @@ Volume :doc:`prune <markdown/podman-volume-prune.1>` Remove all unused volumes -:doc:`rm <markdown/podman-volume-rm.1>` Remove one or more volumes
\ No newline at end of file +:doc:`rm <markdown/podman-volume-rm.1>` Remove one or more volumes diff --git a/test/install/.gitignore b/test/install/.gitignore index 0a948f916..fc29e5c69 100644 --- a/test/install/.gitignore +++ b/test/install/.gitignore @@ -1 +1 @@ -rpms/
\ No newline at end of file +rpms/ diff --git a/test/install/README.md b/test/install/README.md index 21e5ab26d..7150314a6 100644 --- a/test/install/README.md +++ b/test/install/README.md @@ -8,4 +8,4 @@ make -f .copr/Makefile srpm outdir=test/install/rpms make -f .copr/Makefile build_binary outdir=test/install/rpms ``` -Then, run a container image build using the Dockerfiles in this directory.
\ No newline at end of file +Then, run a container image build using the Dockerfiles in this directory. diff --git a/test/trust_set_test.json b/test/trust_set_test.json index 661e65922..f1fdf779c 100644 --- a/test/trust_set_test.json +++ b/test/trust_set_test.json @@ -5,4 +5,4 @@ } ], "transports": null -}
\ No newline at end of file +} |