mirror of
https://github.com/SigNoz/signoz.git
synced 2026-11-11 10:51:01 +00:00
Compare commits
4 Commits
srikanth/t
...
ns/githook
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3c6c700a73 | ||
|
|
872194dbee | ||
|
|
bfaac7a7cc | ||
|
|
f1010908db |
39
.githooks/commit-msg
Executable file
39
.githooks/commit-msg
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
msg_file="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
|
||||
|
||||
if [ -d frontend/node_modules ] && command -v pnpm >/dev/null 2>&1; then
|
||||
(cd frontend && pnpm exec commitlint --edit "$msg_file")
|
||||
else
|
||||
# Header-only fallback for @commitlint/config-conventional when node_modules is absent.
|
||||
header="$(grep -v '^#' "$msg_file" | grep -m1 -v '^[[:space:]]*$' || true)"
|
||||
case "$header" in
|
||||
Merge\ * | Revert\ * | fixup!\ * | squash!\ * | amend!\ *) ;;
|
||||
*)
|
||||
if ! printf '%s\n' "$header" | grep -Eq '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([^)]+\))?!?: [^ ].*$' ||
|
||||
[ "${#header}" -gt 100 ]; then
|
||||
echo "commit-msg: header must be '<type>(<scope>): <subject>', at most 100 chars" >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||
|
||||
if [ -n "$TERM" ] && [ "$TERM" != "dumb" ]; then
|
||||
color_red="$(tput setaf 1)"
|
||||
bold="$(tput bold)"
|
||||
reset="$(tput sgr0)"
|
||||
else
|
||||
color_red=""
|
||||
bold=""
|
||||
reset=""
|
||||
fi
|
||||
|
||||
if [ "$branch" = "main" ]; then
|
||||
echo "${color_red}${bold}You can't commit directly to the main branch${reset}"
|
||||
exit 1
|
||||
fi
|
||||
28
.githooks/install
Executable file
28
.githooks/install
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
# Idempotent; run by make and the frontend postinstall.
|
||||
|
||||
set -e
|
||||
|
||||
git rev-parse --git-dir >/dev/null 2>&1 || exit 0
|
||||
|
||||
git config --local --unset-all core.hooksPath 2>/dev/null || true
|
||||
|
||||
# A global/system core.hooksPath would receive the stubs and shadow .git/hooks.
|
||||
if global_path="$(git config --get core.hooksPath)"; then
|
||||
echo "githooks: core.hooksPath=$global_path is set outside this repo; hooks not installed" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
hooks_dir="$(git rev-parse --git-path hooks)"
|
||||
mkdir -p "$hooks_dir"
|
||||
|
||||
for hook in pre-commit commit-msg; do
|
||||
cat >"$hooks_dir/$hook" <<EOF
|
||||
#!/bin/sh
|
||||
# Generated by .githooks/install.
|
||||
root="\$(git rev-parse --show-toplevel)"
|
||||
[ -x "\$root/.githooks/$hook" ] || exit 0
|
||||
exec "\$root/.githooks/$hook" "\$@"
|
||||
EOF
|
||||
chmod +x "$hooks_dir/$hook"
|
||||
done
|
||||
33
.githooks/pre-commit
Executable file
33
.githooks/pre-commit
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
IFS='
|
||||
'
|
||||
|
||||
go_files=$(git diff --cached --name-only --diff-filter=ACM -- '*.go')
|
||||
if [ -n "$go_files" ] && command -v gofmt >/dev/null 2>&1; then
|
||||
partially_staged=""
|
||||
for f in $go_files; do
|
||||
[ -n "$(git show ":$f" | gofmt -l)" ] || continue
|
||||
if git diff --quiet -- "$f"; then
|
||||
gofmt -w "$f"
|
||||
git add -- "$f"
|
||||
else
|
||||
partially_staged="$partially_staged
|
||||
$f"
|
||||
fi
|
||||
done
|
||||
if [ -n "$partially_staged" ]; then
|
||||
echo "pre-commit: unformatted and partially staged, run gofmt -w and restage:$partially_staged" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$(git diff --cached --name-only --diff-filter=ACM -- frontend/)" ]; then
|
||||
if [ ! -d frontend/node_modules ] || ! command -v pnpm >/dev/null 2>&1; then
|
||||
echo "pre-commit: frontend changes need dependencies, run: cd frontend && pnpm install" >&2
|
||||
exit 1
|
||||
fi
|
||||
(cd frontend && pnpm exec lint-staged)
|
||||
fi
|
||||
6
Makefile
6
Makefile
@@ -35,6 +35,12 @@ DOCKERFILE_ENTERPRISE = $(SRC)/cmd/enterprise/Dockerfile
|
||||
DOCKER_REGISTRY_ENTERPRISE ?= docker.io/signoz/signoz
|
||||
JS_BUILD_CONTEXT = $(SRC)/frontend
|
||||
|
||||
##############################################################
|
||||
# git hooks
|
||||
##############################################################
|
||||
# Expanded at parse time, so any make target installs the hooks.
|
||||
GITHOOKS_INSTALL := $(shell sh $(SRC)/.githooks/install >/dev/null 2>&1 || true)
|
||||
|
||||
##############################################################
|
||||
# directories
|
||||
##############################################################
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
cd frontend && pnpm run commitlint --edit $1
|
||||
|
||||
branch="$(git rev-parse --abbrev-ref HEAD)"
|
||||
|
||||
if [ -n "$TERM" ] && [ "$TERM" != "dumb" ]; then
|
||||
color_red="$(tput setaf 1)"
|
||||
bold="$(tput bold)"
|
||||
reset="$(tput sgr0)"
|
||||
else
|
||||
color_red=""
|
||||
bold=""
|
||||
reset=""
|
||||
fi
|
||||
|
||||
if [ "$branch" = "main" ]; then
|
||||
echo "${color_red}${bold}You can't commit directly to the main branch${reset}"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
cd frontend && pnpm lint-staged
|
||||
@@ -20,8 +20,7 @@
|
||||
"jest": "jest",
|
||||
"jest:coverage": "jest --coverage",
|
||||
"jest:watch": "jest --watch",
|
||||
"postinstall": "pnpm i18n:generate-hash && (is-ci || pnpm husky:configure) && node scripts/update-registry.cjs",
|
||||
"husky:configure": "cd .. && husky install frontend/.husky && cd frontend && chmod ug+x .husky/*",
|
||||
"postinstall": "pnpm i18n:generate-hash && (is-ci || sh ../.githooks/install) && node scripts/update-registry.cjs",
|
||||
"commitlint": "commitlint --edit $1",
|
||||
"test": "jest",
|
||||
"test:changedsince": "jest --changedSince=main --coverage --silent",
|
||||
@@ -186,7 +185,6 @@
|
||||
"@typescript/native-preview": "7.0.0-dev.20260430.1",
|
||||
"eslint-plugin-sonarjs": "4.0.2",
|
||||
"glob": "^13.0.6",
|
||||
"husky": "^7.0.4",
|
||||
"is-ci": "^3.0.1",
|
||||
"jest-environment-jsdom": "29.7.0",
|
||||
"jest-styled-components": "^7.2.0",
|
||||
|
||||
10
frontend/pnpm-lock.yaml
generated
10
frontend/pnpm-lock.yaml
generated
@@ -440,9 +440,6 @@ importers:
|
||||
glob:
|
||||
specifier: ^13.0.6
|
||||
version: 13.0.6
|
||||
husky:
|
||||
specifier: ^7.0.4
|
||||
version: 7.0.4
|
||||
is-ci:
|
||||
specifier: ^3.0.1
|
||||
version: 3.0.1
|
||||
@@ -5529,11 +5526,6 @@ packages:
|
||||
resolution: {integrity: sha512-eKCa6bwnJhvxj14kZk5NCPc6Hb6BdsU9DZcOnmQKSnO1VKrfV0zCvtttPZUsBvjmNDn8rpcJfpwSYnHBjc95MQ==}
|
||||
engines: {node: '>=18.18.0'}
|
||||
|
||||
husky@7.0.4:
|
||||
resolution: {integrity: sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==}
|
||||
engines: {node: '>=12'}
|
||||
hasBin: true
|
||||
|
||||
hyphenate-style-name@1.0.4:
|
||||
resolution: {integrity: sha512-ygGZLjmXfPHj+ZWh6LwbC37l43MhfztxetbFCoYTM2VjkIUpeHgSNn7QIyVFj7YQ1Wl9Cbw5sholVJPzWvC2MQ==}
|
||||
|
||||
@@ -14636,8 +14628,6 @@ snapshots:
|
||||
|
||||
human-signals@8.0.1: {}
|
||||
|
||||
husky@7.0.4: {}
|
||||
|
||||
hyphenate-style-name@1.0.4: {}
|
||||
|
||||
i18next-browser-languagedetector@6.1.8:
|
||||
|
||||
Reference in New Issue
Block a user