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

fix(deps): remove go-gitlint #2614

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
#!/bin/sh

echo
echo "Checking commit message format..."
echo
RED="\033[0;31m"
END_COLOR="\033[0m"

make lint-commit COMMIT_MSG_FILE=$1
commit_types="(chore|docs|feat|fix|refactor|tests?)"
conventional_commit_regex="^${commit_types}(\([a-z \-]+\))?!?: .+$"

commit_message=$(cat "$1")

if [[ "$commit_message" =~ $conventional_commit_regex ]]; then
echo "Commit message meets Conventional Commit standards..."
exit 0
fi
echo
echo "${RED}Commit lint failed. Please update your commit message format. ${END_COLOR}"
echo "Example commit messages:"
echo " feat(scope): add your feature description here"
echo " fix(scope): add your fix description here"
echo " chore(scope): add your chore description here"
echo " docs(scope): add your docs description here"
echo " refactor(scope): add your refactor description here"
echo " tests(scope): add your tests description here"
echo

exit 1
13 changes: 2 additions & 11 deletions build/lint.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ GOLINTER ?= golangci-lint
GO_MOD_OUTDATED ?= go-mod-outdated
MISSPELL ?= misspell

COMMIT_LINT_CMD ?= go-gitlint
COMMIT_LINT_REGEX ?= "(chore|docs|feat|fix|refactor|tests?)(\([^\)]+\))?: .*"
COMMIT_LINT_START ?= "2020-06-24"


EXCLUDEDIR ?= .git
SRCDIR ?= .
GO_PKGS ?= $(shell ${GO} list ./... | grep -v -e "/example")
FILES ?= $(shell find ${SRCDIR} -type f | grep -v -e '.git/' -e '/vendor/' -e 'go.sum')
GO_FILES ?= $(shell find $(SRCDIR) -type f -name "*.go" | grep -v -e ".git/" -e '/example/')
PROJECT_MODULE ?= $(shell $(GO) list -m)

lint: deps spell-check gofmt lint-commit golangci goimports outdated
lint: deps spell-check gofmt golangci goimports outdated
lint-fix: deps spell-check-fix gofmt-fix goimports

#
Expand All @@ -47,10 +42,6 @@ goimports: deps
@echo "=== $(PROJECT_NAME) === [ goimports ]: Checking imports with $(GOIMPORTS)..."
@$(GOIMPORTS) -l -w -local $(PROJECT_MODULE) $(GO_FILES)

lint-commit: deps
@echo "=== $(PROJECT_NAME) === [ lint-commit ]: Checking that commit messages are properly formatted ($(COMMIT_LINT_CMD))..."
@$(COMMIT_LINT_CMD) --since=$(COMMIT_LINT_START) --subject-minlen=10 --subject-maxlen=120 --subject-regex=$(COMMIT_LINT_REGEX)

golangci: deps
@echo "=== $(PROJECT_NAME) === [ golangci-lint ]: Linting using $(GOLINTER) ($(COMMIT_LINT_CMD))..."
@$(GOLINTER) run
Expand All @@ -59,4 +50,4 @@ outdated: deps tools-outdated
@echo "=== $(PROJECT_NAME) === [ outdated ]: Finding outdated deps with $(GO_MOD_OUTDATED)..."
@$(GO) list -u -m -json all | $(GO_MOD_OUTDATED) -direct -update

.PHONY: lint spell-check spell-check-fix gofmt gofmt-fix lint-fix lint-commit outdated goimports
.PHONY: lint spell-check spell-check-fix gofmt gofmt-fix lint-fix outdated goimports
Loading
Loading