mirror of
https://github.com/podman-desktop/podman-desktop
synced 2026-04-21 09:37:22 +00:00
chore: use git hooks for linter/formatter and signed-off/conventional-commits (#2847)
* chore: use pre-commit hook for linter/formatter fixes https://github.com/containers/podman-desktop/issues/2845 Signed-off-by: Florent Benoit <fbenoit@redhat.com>
This commit is contained in:
parent
79a9644a39
commit
6964c15543
5 changed files with 734 additions and 16 deletions
46
.husky/commit-msg
Executable file
46
.husky/commit-msg
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
#!/usr/bin/env sh
|
||||
#
|
||||
# Copyright (C) 2023 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
set -u
|
||||
|
||||
# avoid [[ which is not POSIX sh.
|
||||
if test "$#" != 1; then
|
||||
echo "$0 requires an argument."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test ! -f "$1"; then
|
||||
echo "file does not exist: $1"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
yarn commitlint --edit "$1"
|
||||
|
||||
SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
|
||||
grep -qs "^$SOB" "$1" || echo "$SOB" >>"$1"
|
||||
|
||||
# Catches duplicate Signed-off-by lines.
|
||||
|
||||
test "" = "$(grep '^Signed-off-by: ' "$1" |
|
||||
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
|
||||
echo >&2 Duplicate Signed-off-by lines.
|
||||
exit 1
|
||||
}
|
||||
21
.husky/pre-commit
Executable file
21
.husky/pre-commit
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env sh
|
||||
#
|
||||
# Copyright (C) 2023 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
|
||||
yarn lint-staged
|
||||
1
commitlint.config.cjs
Normal file
1
commitlint.config.cjs
Normal file
|
|
@ -0,0 +1 @@
|
|||
module.exports = { extends: ['@commitlint/config-conventional'] };
|
||||
14
package.json
14
package.json
|
|
@ -70,9 +70,19 @@
|
|||
"typecheck:renderer": "npm run build:preload:types && tsc --noEmit -p packages/renderer/tsconfig.json",
|
||||
"typecheck": "npm run typecheck:main && npm run typecheck:preload && npm run typecheck:renderer && npm run typecheck:preload-dd-extension",
|
||||
"website:build": "cd website && yarn run docusaurus build",
|
||||
"website:dev": "cd website && yarn run docusaurus start"
|
||||
"website:dev": "cd website && yarn run docusaurus start",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,ts,tsx,svelte}": [
|
||||
"eslint --cache --fix",
|
||||
"prettier --write"
|
||||
],
|
||||
"*.{md,css,json}": "prettier --write"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^17.6.5",
|
||||
"@commitlint/config-conventional": "^17.6.5",
|
||||
"@playwright/test": "^1.35.0",
|
||||
"@rollup/plugin-commonjs": "^25.0.1",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
|
|
@ -100,6 +110,8 @@
|
|||
"eslint-plugin-import": "^2.27.5",
|
||||
"eslint-plugin-redundant-undefined": "^0.4.0",
|
||||
"eslint-plugin-sonarjs": "^0.19.0",
|
||||
"husky": "^8.0.0",
|
||||
"lint-staged": "^13.2.2",
|
||||
"nock": "^13.3.1",
|
||||
"playwright": "1.35.0",
|
||||
"postcss-import": "^15.1.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue