Thanks to visit codestin.com
Credit goes to github.com

Skip to content

chore: format scripts #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

usage() {
cat <<EOF
cat << EOF
Usage: $0 [OPTIONS] [<MODULE> <VERSION>]

Create annotated git tags for module releases.
Expand All @@ -28,7 +28,7 @@ EOF

check_getopt() {
# Check if we have GNU or BSD getopt.
if getopt --test >/dev/null 2>&1; then
if getopt --test > /dev/null 2>&1; then
# Exit status 4 means GNU getopt is available.
if [[ $? -ne 4 ]]; then
echo "Error: GNU getopt is not available." >&2
Expand All @@ -50,10 +50,10 @@ maybe_dry_run() {
}

get_readme_version() {
grep -o 'version *= *"[0-9]\+\.[0-9]\+\.[0-9]\+"' "$1" |
head -1 |
grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' ||
echo "0.0.0"
grep -o 'version *= *"[0-9]\+\.[0-9]\+\.[0-9]\+"' "$1" \
| head -1 \
| grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' \
|| echo "0.0.0"
}

list_modules() {
Expand Down Expand Up @@ -131,29 +131,29 @@ eval set -- "$temp"

while true; do
case "$1" in
-l | --list)
list=true
shift
;;
-d | --dry-run)
dry_run=true
shift
;;
-p | --push)
push=true
shift
;;
-h | --help)
usage
;;
--)
shift
break
;;
*)
echo "Error: Internal error!" >&2
exit 1
;;
-l | --list)
list=true
shift
;;
-d | --dry-run)
dry_run=true
shift
;;
-p | --push)
push=true
shift
;;
-h | --help)
usage
;;
--)
shift
break
;;
*)
echo "Error: Internal error!" >&2
exit 1
;;
esac
done

Expand All @@ -178,7 +178,7 @@ if ! tag_name=$(get_tag_name "$module" "$version"); then
exit 1
fi

if git rev-parse -q --verify "refs/tags/$tag_name" >/dev/null 2>&1; then
if git rev-parse -q --verify "refs/tags/$tag_name" > /dev/null 2>&1; then
echo "Notice: Tag '$tag_name' already exists" >&2
else
maybe_dry_run git tag -a "$tag_name" -m "Release $module v$version"
Expand Down
40 changes: 20 additions & 20 deletions update_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euo pipefail

usage() {
cat <<EOF
cat << EOF
Usage: $0 [OPTIONS] <MODULE> <VERSION>

Update or check the version in a module's README.md file.
Expand Down Expand Up @@ -63,14 +63,14 @@ update_version() {

print
}
' "$file" >"$tmpfile" && mv "$tmpfile" "$file"
' "$file" > "$tmpfile" && mv "$tmpfile" "$file"
}

get_readme_version() {
grep -o 'version *= *"[0-9]\+\.[0-9]\+\.[0-9]\+"' "$1" |
head -1 |
grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' ||
echo "0.0.0"
grep -o 'version *= *"[0-9]\+\.[0-9]\+\.[0-9]\+"' "$1" \
| head -1 \
| grep -o '[0-9]\+\.[0-9]\+\.[0-9]\+' \
|| echo "0.0.0"
}

# Set defaults.
Expand All @@ -79,20 +79,20 @@ check_only=false
# Parse command-line options.
while [[ $# -gt 0 ]]; do
case "$1" in
-c | --check)
check_only=true
shift
;;
-h | --help)
usage 0
;;
-*)
echo "Error: Unknown option: $1" >&2
usage 1
;;
*)
break
;;
-c | --check)
check_only=true
shift
;;
-h | --help)
usage 0
;;
-*)
echo "Error: Unknown option: $1" >&2
usage 1
;;
*)
break
;;
esac
done

Expand Down