shfmt -w globally

This commit is contained in:
Earl Warren 2024-08-07 08:31:33 +02:00
parent 4e207414d4
commit d5f66e4c0a
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
27 changed files with 378 additions and 375 deletions

View file

@ -1,6 +1,6 @@
# SPDX-License-Identifier: MIT
FIXTURES_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
FIXTURES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source $FIXTURES_DIR/fixtures/storage.sh
source $FIXTURES_DIR/fixtures/doctor.sh

View file

@ -15,7 +15,7 @@ function fixture_get_paths_s3() {
(
mc ls --quiet --recursive testS3/$path | sed -e "s|.* |$path/|"
) > $DIR/path
) >$DIR/path
}
function fixture_content_search_s3() {
@ -23,15 +23,15 @@ function fixture_content_search_s3() {
local expected="$2"
fixture_get_paths_s3 $path
if test $(wc -l < $DIR/path) -lt 1 ; then
echo expected at least one but got "'$(cat $DIR/path)'"
return 1
if test $(wc -l <$DIR/path) -lt 1; then
echo expected at least one but got "'$(cat $DIR/path)'"
return 1
fi
for filename in $(cat $DIR/path) ; do
local content=$(mc cat testS3/$filename | base64 -w0)
if test "$content" = "$expected" ; then
return 0
fi
for filename in $(cat $DIR/path); do
local content=$(mc cat testS3/$filename | base64 -w0)
if test "$content" = "$expected"; then
return 0
fi
done
echo nothing in $path found with the expected content "$expected"
return 1
@ -41,7 +41,10 @@ function fixture_get_paths_local() {
local path=$1
local work_path=$DIR/forgejo-work-path
( cd $work_path ; find $path -type f) > $DIR/path
(
cd $work_path
find $path -type f
) >$DIR/path
}
function fixture_get_one_path() {
@ -50,7 +53,7 @@ function fixture_get_one_path() {
fixture_get_paths_$storage $path
if test $(wc -l < $DIR/path) != 1 ; then
if test $(wc -l <$DIR/path) != 1; then
echo expected one path but got
cat $DIR/path
return 1
@ -77,7 +80,7 @@ function fixture_lfs_create() {
(
cd $DIR/fixture
git lfs track "*.txt"
echo CONTENT > file.txt
echo CONTENT >file.txt
git add .
git commit -m 'lfs files'
git push
@ -87,11 +90,11 @@ function fixture_lfs_create() {
function fixture_lfs_assert() {
local d=$(mktemp -d)
(
git clone http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO} $d/${FORGEJO_REPO}
cd $d/${FORGEJO_REPO}
rm file.txt
git clone http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO} $d/${FORGEJO_REPO}
cd $d/${FORGEJO_REPO}
rm file.txt
git-lfs checkout file.txt
test -f file.txt
test -f file.txt
)
rm -fr $d
}
@ -110,7 +113,7 @@ function fixture_lfs_assert_local() {
}
function fixture_packages_create() {
echo PACKAGE_CONTENT > $DIR/fixture/package
echo PACKAGE_CONTENT >$DIR/fixture/package
forgejo-curl.sh api_json -X DELETE http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt || true
forgejo-curl.sh api_json --upload-file $DIR/fixture/package http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt
}
@ -128,7 +131,7 @@ function fixture_packages_assert_local() {
}
function fixture_avatars_create() {
echo -n $ONEPIXEL | base64 --decode > $DIR/avatar.png
echo -n $ONEPIXEL | base64 --decode >$DIR/avatar.png
forgejo-curl.sh web --form avatar=@$DIR/avatar.png http://${HOST_PORT}/user/settings/avatar
}
@ -145,7 +148,7 @@ function fixture_avatars_assert_local() {
}
function fixture_repo_avatars_create() {
echo -n $ONEPIXEL | base64 --decode > $DIR/repo-avatar.png
echo -n $ONEPIXEL | base64 --decode >$DIR/repo-avatar.png
forgejo-curl.sh web --form avatar=@$DIR/repo-avatar.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/settings/avatar
# v1.21 only
#forgejo-curl.sh api_json -X POST --data-raw '{"body":"'$avatar'"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/avatar
@ -166,17 +169,17 @@ function fixture_repo_avatars_assert_local() {
}
function fixture_attachments_create_1_18() {
echo -n $ONEPIXEL | base64 --decode > $DIR/attachment.png
echo -n $ONEPIXEL | base64 --decode >$DIR/attachment.png
forgejo-curl.sh web --trace-ascii - --form file=@$DIR/attachment.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/issues/attachments
}
function fixture_attachments_create() {
if forgejo-curl.sh api_json http://${HOST_PORT}/api/v1/version | grep --quiet --fixed-strings 1.18. ; then
if forgejo-curl.sh api_json http://${HOST_PORT}/api/v1/version | grep --quiet --fixed-strings 1.18.; then
fixture_attachments_create_1_18
return
fi
id=$(forgejo-curl.sh api_json --data-raw '{"title":"TITLE"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues | jq .id)
echo -n $ONEPIXEL | base64 --decode > $DIR/attachment.png
echo -n $ONEPIXEL | base64 --decode >$DIR/attachment.png
forgejo-curl.sh api --form name=attachment.png --form attachment=@$DIR/attachment.png http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues/$id/assets
}
@ -206,18 +209,18 @@ function fixture_create() {
git remote add origin http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}
git config user.email root@example.com
git config user.name username
echo SOMETHING > README
echo SOMETHING >README
git add README
git commit -m 'initial commit'
git push --set-upstream --force origin main
)
for fun in ${STORAGE_FUN} ; do
for fun in ${STORAGE_FUN}; do
fixture_${fun}_create
done
}
function fixture_assert() {
for fun in lfs ; do
for fun in lfs; do
fixture_${fun}_assert
done
}