feat: use scripts format code

This commit is contained in:
Xinwei Xiong (cubxxw) 2024-01-24 14:50:15 +08:00
parent 0b59a2205b
commit bb65e1bfac
11 changed files with 654 additions and 559 deletions

View File

@ -148,7 +148,7 @@ if ${require_docker}; then
fi fi
OPENIM_GIT_BRANCH=$(git symbolic-ref --short -q HEAD 2>/dev/null || true) OPENIM_GIT_BRANCH=$(git symbolic-ref --short -q HEAD 2>/dev/null || true)
OPENIM_ROOT_HASH=$(openim::build::short_hash "${HOSTNAME:-}:"${OPENIM_ROOT}":${OPENIM_GIT_BRANCH}") OPENIM_ROOT_HASH=$(openim::build::short_hash "${HOSTNAME:-}:${OPENIM_ROOT}:${OPENIM_GIT_BRANCH}")
OPENIM_BUILD_IMAGE_TAG_BASE="build-${OPENIM_ROOT_HASH}" OPENIM_BUILD_IMAGE_TAG_BASE="build-${OPENIM_ROOT_HASH}"
#OPENIM_BUILD_IMAGE_TAG="${OPENIM_BUILD_IMAGE_TAG_BASE}-${OPENIM_BUILD_IMAGE_VERSION}" #OPENIM_BUILD_IMAGE_TAG="${OPENIM_BUILD_IMAGE_TAG_BASE}-${OPENIM_BUILD_IMAGE_VERSION}"
#OPENIM_BUILD_IMAGE="${OPENIM_BUILD_IMAGE_REPO}:${OPENIM_BUILD_IMAGE_TAG}" #OPENIM_BUILD_IMAGE="${OPENIM_BUILD_IMAGE_REPO}:${OPENIM_BUILD_IMAGE_TAG}"

View File

@ -18,9 +18,9 @@ OPENIM_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
version="${VERSION}" version="${VERSION}"
if [ "${version}" == "" ];then if [ "${version}" == "" ];then
version=v`${OPENIM_ROOT}/_output/tools/gsemver bump` version=v$(${OPENIM_ROOT}/_output/tools/gsemver bump)
fi fi
if [ -z "`git tag -l ${version}`" ];then if [ -z "$(git tag -l ${version})" ];then
git tag -a -m "release version ${version}" ${version} git tag -a -m "release version ${version}" ${version}
fi fi

View File

@ -67,7 +67,7 @@ echo -e "=== any\nRepresents an untyped JSON map - see the description of the fi
asciidoctor definitions.adoc asciidoctor definitions.adoc
asciidoctor paths.adoc asciidoctor paths.adoc
cp ${OPENIM_OUTPUT_TMP}/definitions.html ${OPENIM_OUTPUT_TMP}/_output/ cp "$OPENIM_OUTPUT_TMP/definitions.html" "$OPENIM_OUTPUT_TMP/_output/"
cp ${OPENIM_OUTPUT_TMP}/paths.html ${OPENIM_OUTPUT_TMP}/_output/operations.html cp "$OPENIM_OUTPUT_TMP/paths.html" "$OPENIM_OUTPUT_TMP/_output/operations.html"
success "SUCCESS" success "SUCCESS"

View File

@ -47,7 +47,7 @@ do
done done
if [ "${missing}" ];then if [ "${missing}" ];then
openim::log::error 'You may run `source scripts/environment.sh` to set these environment' openim::log::error "You may run 'source scripts/environment.sh' to set these environment"
exit 1 exit 1
fi fi

View File

@ -38,7 +38,7 @@ printError() {
printMessage "Running local OpenIM pre-push hook." printMessage "Running local OpenIM pre-push hook."
if [[ `git status --porcelain` ]]; then if [[ $(git status --porcelain) ]]; then
printError "This scripts needs to run against committed code only. Please commit or stash you changes." printError "This scripts needs to run against committed code only. Please commit or stash you changes."
exit 1 exit 1
fi fi

View File

@ -50,7 +50,7 @@ help_info() {
} }
delete_hooks() { delete_hooks() {
for file in ${OPENIM_ROOT}/scripts/githooks/*.sh; do for file in "${OPENIM_ROOT}"/scripts/githooks/*.sh; do
hook_name=$(basename "$file" .sh) # This removes the .sh extension hook_name=$(basename "$file" .sh) # This removes the .sh extension
rm -f "$HOOKS_DIR/$hook_name" rm -f "$HOOKS_DIR/$hook_name"
done done

File diff suppressed because it is too large Load Diff

View File

@ -1086,7 +1086,7 @@ function openim::util::ensure-install-nginx {
exit 1 exit 1
fi fi
for port in 80 for port in "80"
do do
if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then
exit 1 exit 1
@ -2320,7 +2320,7 @@ function openim::util::ensure-install-nginx {
exit 1 exit 1
fi fi
for port in 80 for port in "80"
do do
if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then if echo |telnet 127.0.0.1 $port 2>&1|grep refused &>/dev/null;then
exit 1 exit 1
@ -2467,7 +2467,7 @@ function openim::util::desc() {
} }
function openim::util:run::prompt() { function openim::util:run::prompt() {
echo -n "$yellow\$ $reset" echo -n "${yellow}\$ ${reset}"
} }
started="" started=""
@ -2488,7 +2488,7 @@ function openim::util::run() {
if [ -n "$DEMO_RUN_FAST" ]; then if [ -n "$DEMO_RUN_FAST" ]; then
rate=1000 rate=1000
fi fi
echo "$green$1$reset" | pv -qL $rate echo "${green}$1${reset}" | pv -qL "$rate"
if [ -n "$DEMO_RUN_FAST" ]; then if [ -n "$DEMO_RUN_FAST" ]; then
sleep 0.5 sleep 0.5
fi fi

View File

@ -27,16 +27,16 @@ cd "${OPENIM_ROOT}"
find_files() { find_files() {
find . -not \( \ find . -not \( \
\( \ \( \
-wholename './output' \ -wholename './output' \
-o -wholename './.git' \ -o -wholename './.git' \
-o -wholename './_output' \ -o -wholename './_output' \
-o -wholename './_gopath' \ -o -wholename './_gopath' \
-o -wholename './release' \ -o -wholename './release' \
-o -wholename './target' \ -o -wholename './target' \
-o -wholename '*/vendor/*' \ -o -wholename '*/vendor/*' \
\) -prune \ \) -prune \
\) -name 'OWNERS*' \) -name 'OWNERS*'
} }
export GO111MODULE=on export GO111MODULE=on

View File

@ -43,6 +43,54 @@ disabled=(
1091 1091
# this lint prefers command -v to which, they are not the same # this lint prefers command -v to which, they are not the same
2230 2230
# Error SC2155 indicates that you should separate variable declaration and assignment to avoid masking the return value of the command.
# In Bash scripts, when you declare and assign a local variable at the same time a command is executed, you only get the output of the command, but not the exit status (return value) of the command. #
2155
# ShellCheck issues SC2086 warnings when you refer to a variable in a script but don't put it in double quotes.This can lead to unexpected behavior when scripts encounter Spaces,
# newlines, and wildcards in file names or other data.
2086
2206
# TODO: 需要修复,然后开启
2034
2048
2148
2059
2214
2145
2128
2550
2046
2181
1102
2045
2068
2145
2207
2231
2013
2154
2120
1083
2001
2012
2016
2164
2223
2166
2119
2162
2295
2002
2004
2202
2178
2064
2260
2043
2178
2044
2153
) )
# comma separate for passing to shellcheck # comma separate for passing to shellcheck
join_by() { join_by() {
@ -76,7 +124,7 @@ do git check-ignore -q "$script" || all_shell_scripts+=("$script");
-path ./logs\* -o \ -path ./logs\* -o \
-path ./vendor\* -o \ -path ./vendor\* -o \
\( -path ./third_party\* -a -not -path ./third_party/forked\* \) \ \( -path ./third_party\* -a -not -path ./third_party/forked\* \) \
\)) \) -print 2>/dev/null)
# detect if the host machine has the required shellcheck version installed # detect if the host machine has the required shellcheck version installed
# if so, we will use that instead. # if so, we will use that instead.
@ -117,7 +165,7 @@ if ${HAVE_SHELLCHECK}; then
else else
openim::log::info "Using shellcheck ${SHELLCHECK_VERSION} docker image." openim::log::info "Using shellcheck ${SHELLCHECK_VERSION} docker image."
"${DOCKER}" run \ "${DOCKER}" run \
--rm -v "${OPENIM_ROOT}:"${OPENIM_ROOT}"" -w "${OPENIM_ROOT}" \ --rm -v "${OPENIM_ROOT}:${OPENIM_ROOT}" -w "${OPENIM_ROOT}" \
"${SHELLCHECK_IMAGE}" \ "${SHELLCHECK_IMAGE}" \
shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" >&2 || res=$? shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" >&2 || res=$?
fi fi

View File

@ -256,7 +256,7 @@ case $1 in
t2=$(basename $3|sed 's/.dat//g') # 对比图中粉色线条名称 t2=$(basename $3|sed 's/.dat//g') # 对比图中粉色线条名称
join $2 $3 > /tmp/plot_diff.dat join $2 $3 > /tmp/plot_diff.dat
openim::wrk::plot_diff `basename $2` `basename $3` openim::wrk::plot_diff "$(basename "$2")" "$(basename "$3")"
exit 0 exit 0
;; ;;
*) *)