75 lines
1.4 KiB
Bash
75 lines
1.4 KiB
Bash
|
|
#!/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[@]}"
|