BRANCH_SELECTOR: improved script

This commit is contained in:
XargonWan 2024-02-20 09:42:18 +01:00
parent ceb462379d
commit 998818d57c

View file

@ -1,8 +1,8 @@
#!/bin/bash
# Fetch branches from GitHub API
branches=$(curl -s https://api.github.com/repos/XargonWan/RetroDECK/branches | grep '"name":' | awk -F '"' '{print $4}')
# TODO logger
# Fetch branches from GitHub API excluding "main"
branches=$(curl -s https://api.github.com/repos/XargonWan/RetroDECK/branches | grep '"name":' | awk -F '"' '$4 != "main" {print $4}')
# TODO: logging - Fetching branches from GitHub API
# Create an array to store branch names
branch_array=()
@ -11,10 +11,20 @@ branch_array=()
while IFS= read -r branch; do
branch_array+=("$branch")
done <<< "$branches"
# TODO: logging - Creating array of branch names
# Display branches in a Zenity list dialog
selected_branch=$(zenity --list --title="Select Branch" --column="Branch" "${branch_array[@]}")
# TODO: logger
selected_branch=$(zenity --list --title="Select Branch" --column="Branch" --width=1280 --height=800 "${branch_array[@]}")
# TODO: logging - Displaying branches in Zenity list dialog
# Output selected branch
echo "Selected branch: $selected_branch" # TODO: logger
# Display warning message
if [ $selected_branch ]; then
zenity --question --text="Are you sure you want to move to \"$selected_branch\" branch?"
# Output selected branch
echo "Selected branch: $selected_branch" # TODO: logging - Outputting selected branch
zenity --info --text="The data will be now downloaded, please stand by."
# Do stuff here
else
zenity --warning --text="No branch selected, exiting."
# TODO: logging
fi