Add script to check all KDE source dirs and print any not on master

This commit is contained in:
Tracey Clark 2025-05-21 12:03:12 -05:00
commit 3d7f669138
2 changed files with 81 additions and 0 deletions

6
kde_dev/README.md Executable file
View file

@ -0,0 +1,6 @@
# Utility scripts for KDE development
## get_branches_for_dirs
Gets the branch checked out for each directory under $HOME/kde/src
Prints a list of directories that don't have master checked out, with the branch

View file

@ -0,0 +1,75 @@
#!/usr/bin/env bash
# Update solus package and infra repos
current_date=$(date -I)
pr_dirs=()
# Function to display script usage UPDATE
usage() {
echo "Usage: $0"
echo " -h, --help Display this help message"
echo "This script takes no arguments."
echo ''
echo 'It will check each directory under'
echo ' $HOME/kde/src and print any which are not on master.'
}
# Silence output for these to avoid cli spam
pushd () {
command pushd "$@" > /dev/null
}
popd () {
command popd "$@" > /dev/null
}
# TODO add fix variable --fix / -f and function
# get_branch()
# {
# $(git rev-parse --abbrev-ref HEAD)
# }
get_branch_per_dir () {
for dir in $(ls $HOME/kde/src);
do
# cd or
pushd .
# printf "Checking directory %s\n" ${dir}
dir_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ "${dir_branch}" -ne "master" ]]; then
printf "%s not on master\n" "${dir}"
pr_dirs+=("${dir}")
fi
popd
done
}
print_array () {
a=("$@")
for b in "${a[@]}";
do
echo "$b"
done
}
# TODO
# fix_branches () {
# a=("$@")
# for b in "${a[@]}";
# do
# echo "Fixing $b"
# done
# }
if [[ ( $@ == "--help") || $@ == "-h" ]]
then
usage
exit 0
fi
printf "Getting KDE source directory branches...\n"
get_branch_per_dir
printf "\nNot on master:\n"
print_array "${pr_dirs[@]}"