Skip to content

Commit

Permalink
bin: gitroles will list collections (m/t)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivandeex committed Mar 27, 2022
1 parent b771396 commit 6ba2b2c
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions bin/gitroles
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ dir=$(readlink -f "$0")
dir=$(dirname "$dir")
divan_dir=$(dirname "$dir")
roles_dir=$(readlink -f "$divan_dir/roles")
collections_dir=$(readlink -f "$divan_dir/collections/ansible_collections")

full=0
pull=0
Expand All @@ -19,11 +20,16 @@ case "$1" in
exit 1 ;;
esac

cd "$roles_dir" || exit 1
for role in * ; do
echo
echo ">>>> $role"
if ! cd "$roles_dir/$role"; then
list_items()
{
parent_dir=$(pwd)
[ "$(ls -A)" ] || return
echo ">>> $parent_name <<<"
echo

for item in * ; do
echo ">>>> $item"
if ! cd "$parent_dir/$item"; then
echo "error: cannot access role directory"
continue
fi
Expand All @@ -36,4 +42,16 @@ for role in * ; do
git fetch
git pull --ff-only
fi
echo
done
}

for namespace_dir in "$collections_dir"/* ; do
cd "$namespace_dir" || continue
parent_name="collections/$(basename "$namespace_dir")"
list_items
done

cd "$roles_dir" || exit 1
parent_name=roles
list_items

0 comments on commit 6ba2b2c

Please sign in to comment.