Qual: Update pre-commit for shell script formatting (#37221)
* Qual: Upgrade pre-commit/beautysh, .editorconfig for sh # Qual: Upgrade pre-commit/beautysh, .editorconfig for sh - Upgrade beautysh pre-commit hook (trixie/python 3.13 compatibility); - Indicate tab indent for shell scripts in .editorconfig. * Qual: Update pre-commit hooks configuration - Exclude `dev/initdemo/initdemo.sh` from beautysh hook - Enable shellcheck hook manually - Fix indentation in `initdemo.sh` * Qual: Update pre-commit hook configuration - Update .pre-commit-config.yaml to exclude dolibarr.postrm from beautysh formatting --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
bd2ff84a95
commit
7d89635c5b
4 changed files with 69 additions and 64 deletions
|
|
@ -18,6 +18,8 @@ insert_final_newline = true
|
|||
indent_style = tab
|
||||
[*.css]
|
||||
indent_style = tab
|
||||
[*.sh]
|
||||
indent_style = tab
|
||||
[*.xml]
|
||||
indent_style = tab
|
||||
[*.md]
|
||||
|
|
|
|||
|
|
@ -72,14 +72,16 @@ repos:
|
|||
stages: [manual] # To run: pre-commit run -a --hook-stage=manual actionlint
|
||||
|
||||
# Beautify shell scripts
|
||||
#- repo: https://github.com/lovesegfault/beautysh.git
|
||||
# rev: v6.2.1
|
||||
# hooks:
|
||||
# - id: beautysh
|
||||
# exclude: |
|
||||
# (?x)^(dev/setup/git/hooks/pre-commit
|
||||
# )$
|
||||
# args: [--tab]
|
||||
- repo: https://github.com/lovesegfault/beautysh.git
|
||||
rev: v6.4.2
|
||||
hooks:
|
||||
- id: beautysh
|
||||
exclude: |
|
||||
(?x)^(dev/setup/git/hooks/pre-commit
|
||||
|dev/initdemo/initdemo.sh # indent/outdent mismatch
|
||||
|dev/build/debian/dolibarr.postrm # indent/outdent mismatch
|
||||
)$
|
||||
args: [--tab]
|
||||
|
||||
# Run local script
|
||||
#
|
||||
|
|
@ -246,11 +248,12 @@ repos:
|
|||
- ned
|
||||
|
||||
# Check some shell scripts
|
||||
#- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||
# rev: v0.11.0.1
|
||||
# hooks:
|
||||
# - id: shellcheck
|
||||
# args: [-W, "100"]
|
||||
- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||
rev: v0.11.0.1
|
||||
hooks:
|
||||
- id: shellcheck
|
||||
stages: [manual] # To run: `pre-commit run -a --hook-stage=manual shellcheck`
|
||||
args: [-W, "100"]
|
||||
|
||||
# Check sql file syntax
|
||||
- repo: https://github.com/sqlfluff/sqlfluff
|
||||
|
|
@ -293,4 +296,4 @@ repos:
|
|||
# # virtualmin excluded - reason https://github.com/Dolibarr/dolibarr/pull/36370#issuecomment-3565101823
|
||||
# exclude: (?x)^
|
||||
# (dev/build/perl/virtualmin/dolibarr.pl
|
||||
# )$
|
||||
# across all file typese )$
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
# Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
|
||||
|
||||
#------------------------------------------------------
|
||||
# Script to purge and initialize a database with demo values.
|
||||
|
|
@ -91,7 +91,7 @@ then
|
|||
fichtemp=$(mktemp 2>/dev/null) || fichtemp=/tmp/test$$
|
||||
# shellcheck disable=2064,2172
|
||||
trap "rm -f '$fichtemp'" 0 1 2 5 15
|
||||
$DIALOG --title "Init Dolibarr with demo values" --clear --inputbox "Mysql database name :" 16 55 $base 2> "$fichtemp"
|
||||
$DIALOG --title "Init Dolibarr with demo values" --clear --inputbox "Mysql database name :" 16 55 "$base" 2> "$fichtemp"
|
||||
valret=$?
|
||||
case $valret in
|
||||
0)
|
||||
|
|
@ -107,7 +107,7 @@ then
|
|||
fichtemp=$(mktemp 2>/dev/null) || fichtemp=/tmp/test$$
|
||||
# shellcheck disable=2064,2172
|
||||
trap "rm -f '$fichtemp'" 0 1 2 5 15
|
||||
$DIALOG --title "Init Dolibarr with demo values" --clear --inputbox "Mysql port (ex: 3306):" 16 55 $port 2> "$fichtemp"
|
||||
$DIALOG --title "Init Dolibarr with demo values" --clear --inputbox "Mysql port (ex: 3306):" 16 55 "$port" 2> "$fichtemp"
|
||||
valret=$?
|
||||
|
||||
case $valret in
|
||||
|
|
@ -215,8 +215,8 @@ exit;
|
|||
export documentdir
|
||||
# shellcheck disable=2016
|
||||
documentdir=$(< "$mydir/../../htdocs/conf/conf.php" grep '^\$dolibarr_main_data_root' | sed -e 's/$dolibarr_main_data_root=//' | sed -e 's/;//' | sed -e "s/'//g" | sed -e 's/"//g')
|
||||
if [ "$documentdir" != "" ]
|
||||
then
|
||||
if [ "$documentdir" != "" ]
|
||||
then
|
||||
$DIALOG --title "Reset document directory" --clear --yesno "DELETE and recreate document directory '$documentdir/':" 16 55
|
||||
valret=$?
|
||||
|
||||
|
|
@ -250,20 +250,20 @@ then
|
|||
|
||||
chmod -R u+w "$documentdir/"
|
||||
chown -R www-data "$documentdir/"
|
||||
else
|
||||
else
|
||||
echo "Detection of 'documents' directory in '$mydir' failed so demo files were not copied."
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ -s "$mydir/initdemopostsql.sql" ]; then
|
||||
if [ -s "$mydir/initdemopostsql.sql" ]; then
|
||||
mysql "-P$port" "$base" < "$mydir/initdemopostsql.sql"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
if [ "$res" = "0" ]
|
||||
then
|
||||
if [ "$res" = "0" ]
|
||||
then
|
||||
echo "Success, file successfully loaded."
|
||||
else
|
||||
else
|
||||
echo "Error, load failed."
|
||||
fi
|
||||
echo
|
||||
fi
|
||||
echo
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
# - Some side effects from translations on variables.
|
||||
# - Some other minors side effects to be examined (#, %).
|
||||
#
|
||||
# Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
# Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
|
||||
|
||||
LANG_DIR=htdocs/langs/en_US/
|
||||
MYDIR=$(dirname "$(realpath "$0")")
|
||||
|
|
|
|||
Loading…
Reference in a new issue