Skip to content

Commit

Permalink
Start fixing ShellCheck warnings + stylistic consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
EliahKagan committed Nov 28, 2024
1 parent 34efe03 commit f759702
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 83 deletions.
10 changes: 5 additions & 5 deletions etc/check-package-size.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ set -eu -o pipefail

function enter () {
local dir="${1:?need directory to enter}"
echo -n $' in' $dir $'\t\t'
cd $dir
printf ' in %s \t→\t' "$dir"
cd -- "$dir"
}

function indent () {
"$@" | grep "package size" | while read -r line; do
echo " " $line
"$@" | grep -F 'package size' | while IFS= read -r line; do
echo " $line"
done
}

echo "in root: gitoxide CLI"
echo 'in root: gitoxide CLI'
(enter gix-fsck && indent cargo diet -n --package-size-limit 10KB)
(enter gix-actor && indent cargo diet -n --package-size-limit 10KB)
(enter gix-archive && indent cargo diet -n --package-size-limit 10KB)
Expand Down
81 changes: 41 additions & 40 deletions gix-attributes/tests/fixtures/make_attributes_baseline.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
set -eu -o pipefail

mkdir basics;
mkdir basics

function baseline() {
{
echo "$1"
GIT_ATTR_NOSYSTEM=1 git -c core.attributesFile=$PWD/user.attributes check-attr -a "$1"
GIT_ATTR_NOSYSTEM=1 git -c core.attributesFile="$PWD/user.attributes" check-attr -a "$1"
echo
} >> baseline
}
Expand All @@ -17,39 +17,40 @@ function baseline() {

# based on https://github.com/git/git/blob/140b9478dad5d19543c1cb4fd293ccec228f1240/t/t0003-attributes.sh#L45
mkdir -p a/b/d a/c b
(
echo "[attr]notest !test"
echo "\" d \" test=d"
echo " e test=e"
echo " e\" test=e"
echo "f test=f"
echo "a/i test=a/i"
echo "onoff test -test"
echo "offon -test test"
echo "no notest"
echo "A/e/F test=A/e/F"
echo "\!escaped test-escaped"
echo "**/recursive test-double-star-slash"
echo "a**f test-double-star-no-slash"
echo "dir-slash/ never"
echo "dir/** always"
) > .gitattributes
(
echo "g test=a/g"
echo "b/g test=a/b/g"
) > a/.gitattributes
(
echo "h test=a/b/h"
echo "d/* test=a/b/d/*"
echo "d/yes notest"
) > a/b/.gitattributes
(
echo "global test=global"
echo "z/x/a global-no-wildcard-case-test"
echo "z/x/* global-wildcard-case-test"
) > user.attributes
{
echo '[attr]notest !test'
echo '" d " test=d'
echo ' e test=e'
echo ' e" test=e'
echo 'f test=f'
echo 'a/i test=a/i'
echo 'onoff test -test'
echo 'offon -test test'
echo 'no notest'
echo 'A/e/F test=A/e/F'
echo '\!escaped test-escaped'
echo '**/recursive test-double-star-slash'
echo 'a**f test-double-star-no-slash'
echo 'dir-slash/ never'
echo 'dir/** always'
} > .gitattributes
{
echo 'g test=a/g'
echo 'b/g test=a/b/g'
} > a/.gitattributes
{
echo 'h test=a/b/h'
echo 'd/* test=a/b/d/*'
echo 'd/yes notest'
} > a/b/.gitattributes
{
echo 'global test=global'
echo 'z/x/a global-no-wildcard-case-test'
echo 'z/x/* global-wildcard-case-test'
} > user.attributes

git add . && git commit -qm c1
git add .
git commit -qm c1

baseline z/x/a
baseline Z/x/a
Expand All @@ -67,7 +68,7 @@ function baseline() {
baseline a/recursive
baseline a/b/recursive
baseline a/b/c/recursive
baseline "!escaped"
baseline '!escaped'
baseline af
baseline axf
baseline a/b/d/no
Expand All @@ -77,7 +78,7 @@ function baseline() {
baseline a/B/D/g
baseline b/g
baseline a/c/f
baseline "e\""
baseline 'e"'
baseline a/i
baseline A/b/h
baseline A/B/D/NO
Expand All @@ -100,23 +101,23 @@ mkdir lookup-order
(cd lookup-order

function baseline_selected() {
local path=${1?first argument is the path to match}
local path="${1?first argument is the path to match}"
shift
{
echo "$path"
git -c core.attributesFile=$PWD/user.attributes check-attr $@ -- "$path"
git -c core.attributesFile="$PWD/user.attributes" check-attr "$@" -- "$path"
echo
} >> baseline.selected
}

git init
cat <<EOF > user.attributes
cat <<'EOF' > user.attributes
[attr]my-text text
[attr]my-binary binary
* location=user
EOF
cat <<EOF > .gitattributes
cat <<'EOF' > .gitattributes
[attr]b-cycle a-cycle my-text
[attr]a-cycle b-cycle my-binary
[attr]recursive recursively-assigned-attr
Expand Down
28 changes: 14 additions & 14 deletions gix-date/tests/fixtures/generate_git_date_baseline.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
#!/usr/bin/env bash
set -eu -o pipefail

git init;
git init

function baseline() {
local test_date=$1 # first argument is the date to test
local test_name=$2 # second argument is the format name for re-formatting
local test_date="$1" # first argument is the date to test
local test_name="$2" # second argument is the format name for re-formatting

local status=0
git -c section.key="$test_date" config --type=expiry-date section.key || status="$?"

git -c section.key="$test_date" config --type=expiry-date section.key && status=0 || status=$?
{
echo "$test_date"
echo "$test_name"
echo "$status"
if [ $status == 0 ]
then
git -c section.key="$test_date" config --type=expiry-date section.key
else
echo "-1"
fi
echo "$test_date"
echo "$test_name"
echo "$status"
if [ "$status" = 0 ]; then
git -c section.key="$test_date" config --type=expiry-date section.key
else
echo '-1'
fi
} >> baseline.git
}

Expand All @@ -43,4 +44,3 @@ baseline '1234567890' 'UNIX'
baseline '1660874655 +0800' 'RAW'

# Note that we can't necessarily put 64bit dates here yet as `git` on the system might not yet support it.

16 changes: 8 additions & 8 deletions gix-object/fuzz/fuzz_targets/fuzz_commit_corpus_builder.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/bash
#!/usr/bin/env bash

set -eox pipefail
set -eux -o pipefail

ROOT=$1
OUTPUT_CORPUS=$2
FIXTURES_DIR=$(readlink -f $ROOT/gix-object/tests/fixtures/commit)
root="$1"
output_corpus="$2"
fixtures_dir="$(readlink -f -- "$root/gix-object/tests/fixtures/commit")"

echo $ROOT
echo $FIXTURES_DIR
echo "$root"
echo "$fixtures_dir"

zip -j $OUTPUT_CORPUS $FIXTURES_DIR/*
zip -j "$output_corpus" "$fixtures_dir"/*
16 changes: 8 additions & 8 deletions gix-object/fuzz/fuzz_targets/fuzz_tag_corpus_builder.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/bash
#!/usr/bin/env bash

set -eox pipefail
set -eux -o pipefail

ROOT=$1
OUTPUT_CORPUS=$2
FIXTURES_DIR=$(readlink -f $ROOT/gix-object/tests/fixtures/tag)
root="$1"
output_corpus="$2"
fixtures_dir="$(readlink -f -- "$root/gix-object/tests/fixtures/tag")"

echo $ROOT
echo $FIXTURES_DIR
echo "$root"
echo "$fixtures_dir"

zip -j $OUTPUT_CORPUS $FIXTURES_DIR/*
zip -j "$output_corpus" "$fixtures_dir"/*
16 changes: 8 additions & 8 deletions gix-object/fuzz/fuzz_targets/fuzz_tree_corpus_builder.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/bash
#!/usr/bin/env bash

set -eox pipefail
set -eux -o pipefail

ROOT=$1
OUTPUT_CORPUS=$2
FIXTURES_DIR=$(readlink -f $ROOT/gix-object/tests/fixtures/tree)
root="$1"
output_corpus="$2"
fixtures_dir="$(readlink -f -- "$root/gix-object/tests/fixtures/tree")"

echo $ROOT
echo $FIXTURES_DIR
echo "$root"
echo "$fixtures_dir"

zip -j $OUTPUT_CORPUS $FIXTURES_DIR/*
zip -j "$output_corpus" "$fixtures_dir"/*

0 comments on commit f759702

Please sign in to comment.