mirror of
https://github.com/containers/podman.git
synced 2025-07-02 08:47:43 +08:00
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>
This commit is contained in:
12
.pre-commit-config.yaml
Normal file
12
.pre-commit-config.yaml
Normal file
@ -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
|
9
Makefile
9
Makefile
@ -32,8 +32,10 @@ BUILDTAGS ?= \
|
|||||||
exclude_graphdriver_devicemapper \
|
exclude_graphdriver_devicemapper \
|
||||||
seccomp \
|
seccomp \
|
||||||
varlink
|
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)
|
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")
|
SOURCES = $(shell find . -name "*.go")
|
||||||
|
|
||||||
@ -149,6 +151,11 @@ endif
|
|||||||
touch $@
|
touch $@
|
||||||
|
|
||||||
lint: golangci-lint
|
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
|
golangci-lint: .gopathok varlink_generate .install.golangci-lint
|
||||||
$(GOBIN)/golangci-lint run --tests=false --skip-files swagger.go
|
$(GOBIN)/golangci-lint run --tests=false --skip-files swagger.go
|
||||||
|
@ -48,6 +48,7 @@ WORKDIR $GOSRC
|
|||||||
RUN set -x && \
|
RUN set -x && \
|
||||||
make install.tools && \
|
make install.tools && \
|
||||||
install -D -m 755 $GOSRC/contrib/gate/entrypoint.sh /usr/local/bin/ && \
|
install -D -m 755 $GOSRC/contrib/gate/entrypoint.sh /usr/local/bin/ && \
|
||||||
|
python3 -m pip install pre-commit && \
|
||||||
rm -rf "$GOSRC"
|
rm -rf "$GOSRC"
|
||||||
|
|
||||||
# Install cni config
|
# Install cni config
|
||||||
|
@ -14,4 +14,4 @@ indent_size = 2
|
|||||||
end_of_line = lf
|
end_of_line = lf
|
||||||
charset = utf-8
|
charset = utf-8
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
|
@ -104,4 +104,4 @@ Commands
|
|||||||
|
|
||||||
:doc:`volume <volume>` Manage volumes
|
:doc:`volume <volume>` Manage volumes
|
||||||
|
|
||||||
:doc:`wait <markdown/podman-wait.1>` Block on one or more containers
|
:doc:`wait <markdown/podman-wait.1>` Block on one or more containers
|
||||||
|
@ -7,4 +7,4 @@ Network
|
|||||||
|
|
||||||
:doc:`ls <markdown/podman-network-ls.1>` network list
|
:doc:`ls <markdown/podman-network-ls.1>` network list
|
||||||
|
|
||||||
:doc:`rm <markdown/podman-network-rm.1>` network rm
|
:doc:`rm <markdown/podman-network-rm.1>` network rm
|
||||||
|
@ -8,4 +8,4 @@ Volume
|
|||||||
|
|
||||||
:doc:`prune <markdown/podman-volume-prune.1>` Remove all unused volumes
|
:doc:`prune <markdown/podman-volume-prune.1>` Remove all unused volumes
|
||||||
|
|
||||||
:doc:`rm <markdown/podman-volume-rm.1>` Remove one or more volumes
|
:doc:`rm <markdown/podman-volume-rm.1>` Remove one or more volumes
|
||||||
|
2
test/install/.gitignore
vendored
2
test/install/.gitignore
vendored
@ -1 +1 @@
|
|||||||
rpms/
|
rpms/
|
||||||
|
@ -8,4 +8,4 @@ make -f .copr/Makefile srpm outdir=test/install/rpms
|
|||||||
make -f .copr/Makefile build_binary 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.
|
Then, run a container image build using the Dockerfiles in this directory.
|
||||||
|
@ -5,4 +5,4 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"transports": null
|
"transports": null
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user