feat: use scripts format code

pull/1799/head
Xinwei Xiong (cubxxw) 2 years ago
parent 0b59a2205b
commit bb65e1bfac

@ -148,7 +148,7 @@ if ${require_docker}; then
fi
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="${OPENIM_BUILD_IMAGE_TAG_BASE}-${OPENIM_BUILD_IMAGE_VERSION}"
#OPENIM_BUILD_IMAGE="${OPENIM_BUILD_IMAGE_REPO}:${OPENIM_BUILD_IMAGE_TAG}"

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

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

@ -47,7 +47,7 @@ do
done
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
fi

@ -38,7 +38,7 @@ printError() {
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."
exit 1
fi

@ -50,7 +50,7 @@ help_info() {
}
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
rm -f "$HOOKS_DIR/$hook_name"
done

File diff suppressed because it is too large Load Diff

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

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

@ -43,6 +43,54 @@ disabled=(
1091
# this lint prefers command -v to which, they are not the same
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
join_by() {
@ -76,7 +124,7 @@ do git check-ignore -q "$script" || all_shell_scripts+=("$script");
-path ./logs\* -o \
-path ./vendor\* -o \
\( -path ./third_party\* -a -not -path ./third_party/forked\* \) \
\))
\) -print 2>/dev/null)
# detect if the host machine has the required shellcheck version installed
# if so, we will use that instead.
@ -117,7 +165,7 @@ if ${HAVE_SHELLCHECK}; then
else
openim::log::info "Using shellcheck ${SHELLCHECK_VERSION} docker image."
"${DOCKER}" run \
--rm -v "${OPENIM_ROOT}:"${OPENIM_ROOT}"" -w "${OPENIM_ROOT}" \
--rm -v "${OPENIM_ROOT}:${OPENIM_ROOT}" -w "${OPENIM_ROOT}" \
"${SHELLCHECK_IMAGE}" \
shellcheck "${SHELLCHECK_OPTIONS[@]}" "${all_shell_scripts[@]}" >&2 || res=$?
fi

@ -256,7 +256,7 @@ case $1 in
t2=$(basename $3|sed 's/.dat//g') # 对比图中粉色线条名称
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
;;
*)

Loading…
Cancel
Save