Skip to content

Commit

Permalink
Fix restyle
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-marquez-csa committed Mar 12, 2024
1 parent 420fbb8 commit 881ac01
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion scripts/sdk-doctor/_network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ display_interface_info() {
interfaces=$(ip link show | grep -oP '(?<=^\d: )[e-w]+[0-9a-zA-Z-]+')

# Iterate over each interface and display relevant information
for intf in $interfaces; do
for intf in "$interfaces"; do
display_interface_info "$intf"
echo ""
done
Expand Down
4 changes: 2 additions & 2 deletions scripts/sdk-doctor/_os.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ROOT_DIR=$(realpath $(dirname "$0")/../..)
cd $ROOT_DIR
ROOT_DIR=$(realpath "$(dirname "$0")"/../..)
cd "$ROOT_DIR"

# Function to display OS information
get_os_info() {
Expand Down
54 changes: 27 additions & 27 deletions scripts/sdk-doctor/_repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ROOT_DIR=$(realpath $(dirname "$0")/../..)
cd $ROOT_DIR
ROOT_DIR=$(realpath "$(dirname "$0")"/../..)
cd "$ROOT_DIR"

get_repo_and_branch_info() {
# Input validation
Expand All @@ -39,7 +39,7 @@ get_repo_and_branch_info() {
return 1
fi

cd $path
cd "$path"

# Get the URL of the remote origin
remote_url=$(git config --get remote.origin.url)
Expand All @@ -54,7 +54,7 @@ get_repo_and_branch_info() {
padding_length=$((total_length - text_length))

echo '+-----------------------------------------------------------------------------------------------+'
printf "| %s: %s%*s|\n" "$repo_friendly_name" "$repo_name" $padding_length ""
printf "| %s: %s%*s|\n" "$repo_friendly_name" "$repo_name" "$padding_length" ""
echo '+-----------------------------------------------------------------------------------------------+'
else
# Print error message if there is no remote URL
Expand Down Expand Up @@ -91,7 +91,7 @@ get_repo_and_branch_info() {
echo "Commit Date: $commit_datetime"

# Attempt to find branches that contain this commit
branches=$(git branch --contains $commit_sha | sed 's/^/ /')
branches=$(git branch --contains "$commit_sha" | sed 's/^/ /')

if [ -n "$branches" ]; then
echo "Contained in branches:"
Expand All @@ -105,7 +105,7 @@ get_repo_and_branch_info() {
echo

# Navigate back to the original directory
cd $ROOT_DIR
cd "$ROOT_DIR"
}

trim_commit_message() {
Expand All @@ -114,7 +114,7 @@ trim_commit_message() {
# Check if the commit message contains a newline character
if [[ "$commit_message" == *$'\n'* ]]; then
# Extract the first line of the commit message
local first_line=${commit_message%%$'\n'*}
local first_line="${commit_message%%$'\n'*}"
else
# If there's no newline, use the entire commit message
local first_line="$commit_message"
Expand All @@ -129,24 +129,24 @@ get_repo_and_branch_info "."

# Handle arguments
case "$1" in
--git-sub)
# Initialize an array to hold the directories
declare -a repo_dirs

cd $ROOT_DIR

# Find directories containing a .github folder and store them in the array, excluding the current directory
while IFS= read -r dir; do
# Check if the directory is not the current directory
if [[ "$dir" != "." ]]; then
repo_dirs+=("$dir")
fi
done < <(find . -type d -name .github | awk -F'/[^/]*$' '{print $1}')

# Iterate through the directories and call the function for each
for dir in "${repo_dirs[@]}"; do
get_repo_and_branch_info "$dir"
done
;;
*) ;;
--git-sub)
# Initialize an array to hold the directories
declare -a repo_dirs

cd "$ROOT_DIR"

# Find directories containing a .github folder and store them in the array, excluding the current directory
while IFS= read -r dir; do
# Check if the directory is not the current directory
if [[ "$dir" != "." ]]; then
repo_dirs+=("$dir")
fi
done < <(find . -type d -name .github | awk -F'/[^/]*$' '{print $1}')

# Iterate through the directories and call the function for each
for dir in "${repo_dirs[@]}"; do
get_repo_and_branch_info "$dir"
done
;;
*) ;;
esac
16 changes: 8 additions & 8 deletions scripts/sdk-doctor/_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
# See the License for the specific language governing permissions and
# limitations under the License.

ROOT_DIR=$(realpath $(dirname "$0")/../..)
cd $ROOT_DIR
ROOT_DIR=$(realpath "$(dirname "$0")"/../..)
cd "$ROOT_DIR"

SPEC_VERSION=$(head -n 1 $ROOT_DIR/SPECIFICATION_VERSION)
SPEC_SHA=$(head -n 1 $ROOT_DIR/data_model/spec_sha)
SCRAPPER_VERSION=$(head -n 1 $ROOT_DIR/data_model/scraper_version)
SPEC_VERSION=$(head -n 1 "$ROOT_DIR"/SPECIFICATION_VERSION)
SPEC_SHA=$(head -n 1 "$ROOT_DIR"/data_model/spec_sha)
SCRAPPER_VERSION=$(head -n 1 "$ROOT_DIR"/data_model/scraper_version)

echo 'SPEC VERSION:' $SPEC_VERSION
echo 'SPEC SHA:' $SPEC_SHA
echo 'SCRAPER VERSION:' $SCRAPPER_VERSION
echo 'SPEC VERSION:' "$SPEC_VERSION"
echo 'SPEC SHA:' "$SPEC_SHA"
echo 'SCRAPER VERSION:' "$SCRAPPER_VERSION"
46 changes: 23 additions & 23 deletions scripts/sdk-doctor/sdk-doctor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
echo "$date_string"
echo

ROOT_DIR=$(realpath $(dirname "$0")/../..)
ROOT_DIR=$(realpath "$(dirname "$0")"/../..)
TH_DEV_SCRIPTS_DIR=$ROOT_DIR/scripts/sdk-doctor
cd $ROOT_DIR
cd "$ROOT_DIR"

# Check for arguments
if [ "$#" -gt 1 ]; then
Expand All @@ -79,7 +79,7 @@
max_line_length=$((width - 6)) # Maximum characters in a line before wrapping

# Word-wrap the input text
input_text_wrapped=$(echo -e "$input_text" | fold -w $max_line_length -s)
input_text_wrapped=$(echo -e "$input_text" | fold -w "$max_line_length" -s)

# Calculate height based on the number of lines in the input text
height=$(echo -e "$input_text_wrapped" | wc -l)
Expand All @@ -88,26 +88,26 @@
# Print the top border with title
title_with_padding=" $title "
title_padding_left=$(((width - 2 - ${#title_with_padding}) / 2))
[ $title_padding_left -lt 0 ] && title_padding_left=0
[ "$title_padding_left" -lt 0 ] && title_padding_left=0
title_padding_right=$((width - 2 - ${#title_with_padding} - title_padding_left))
[ $title_padding_right -lt 0 ] && title_padding_right=0
echo '+'$(printf "%0.s-" $(seq 1 $title_padding_left))"$title_with_padding"$(printf "%0.s-" $(seq 1 $title_padding_right))'+'
[ "$title_padding_right" -lt 0 ] && title_padding_right=0
echo '+'"$(printf "%0.s-" "$(seq 1 "$title_padding_left")")$title_with_padding""$(printf "%0.s-" "$(seq 1 "$title_padding_right")")"'+'

# Inner top padding
echo "|$(printf ' %.0s' $(seq 1 $((width - 2))))|"
echo "|$(printf ' %.0s' "$(seq 1 $((width - 2)))")|"

# Print each line of wrapped input text with frame borders and padding
echo -e "$input_text_wrapped" | while IFS= read -r line; do
padding_right=$((width - 4 - ${#line} - 2)) # Subtract 4 for the borders and 2 for the left padding
[ $padding_right -lt 0 ] && padding_right=0
echo "| $line$(printf ' %.0s' $(seq 1 $padding_right)) |"
[ "$padding_right" -lt 0 ] && padding_right=0
echo "| $line$(printf ' %.0s' "$(seq 1 "$padding_right")") |"
done

# Inner bottom padding
echo "|$(printf ' %.0s' $(seq 1 $((width - 2))))|"
echo "|$(printf ' %.0s' "$(seq 1 $((width - 2)))")|"

# Print the bottom border
echo '+'$(printf "%0.s-" $(seq 1 $((width - 2))))'+'
echo '+'"$(printf "%0.s-" "$(seq 1 $((width - 2)))")"'+'
echo
}

Expand Down Expand Up @@ -136,18 +136,18 @@

# Handle arguments
case "$1" in
--system)
show_system
usage
;;
--complete)
show_system
usage
;;
*)
usage
exit 1
;;
--system)
show_system
usage
;;
--complete)
show_system
usage
;;
*)
usage
exit 1
;;
esac

} 2>&1 | tee sdk-doctor.txt

0 comments on commit 881ac01

Please sign in to comment.