Skip to content

Commit

Permalink
refactor(readability): move function opening brace to new line (#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitcoin-tools authored Aug 24, 2024
1 parent 21a9d06 commit 3746502
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 80 deletions.
24 changes: 16 additions & 8 deletions .github/scripts/process_release_tags
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ set -o errexit
set -o nounset

# Error handling function
handle_error() {
handle_error()
{
echo "An error occurred on line $1" >&2
exit 1
}
Expand All @@ -16,7 +17,8 @@ handle_error() {
trap 'if [ $? -gt 0 ]; then handle_error ${LINENO:-}; fi' EXIT

# Error throwing function
throw_error() {
throw_error()
{
# Print the error message to stderr
echo "$1" >&2

Expand All @@ -25,7 +27,8 @@ throw_error() {
}

# Open URL function
open_url() {
open_url()
{
url="$1"
case "${TARGET_KERNEL}" in
Darwin*) open "${url}" ;;
Expand All @@ -36,7 +39,8 @@ open_url() {
}

# Git operations function
push_changes_to_branch() {
push_changes_to_branch()
{
# Stash any changes if there are any
if [ -n "$(git status --porcelain)" ]; then
git stash
Expand All @@ -60,7 +64,8 @@ push_changes_to_branch() {
}

# Prepare to push changes
prepare_to_push_changes() {
prepare_to_push_changes()
{
# Change to the repository directory
cd "${REPO_PATH}"
git fetch origin master
Expand All @@ -72,7 +77,8 @@ prepare_to_push_changes() {
}

# Replace function
replace_in_files() {
replace_in_files()
{
# Replace the old version with the new version in all files
if [ "${TARGET_KERNEL}" = 'Darwin' ]; then
find . -type f -exec env LANG=C sed -i '' "s/$1/$2/g" {} \;
Expand All @@ -81,15 +87,17 @@ replace_in_files() {
fi
}

validate_branch() {
validate_branch()
{
cd "${REPO_PATH}"
git fetch origin
if ! git show-ref --verify --quiet refs/remotes/origin/"$1"; then
throw_error "Branch $1 does not exist on origin. Please enter a valid branch."
fi
}

validate_semver() {
validate_semver()
{
if ! echo "$1" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
throw_error "Invalid version: $1. Version must be in SemVer format without any suffix like '-beta'."
fi
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/validation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ jobs:
--enable require-variable-braces
SHFMT_OPTS: >-
--case-indent
--func-next-line
--indent 2
--space-redirects
Expand Down
Loading

0 comments on commit 3746502

Please sign in to comment.