Commit 5f64ae6f authored by Sébastien Villemot's avatar Sébastien Villemot

Add script list_projects.sh.

parent 495b9b83
......@@ -26,6 +26,12 @@ in commit messages.
to "email addresses" (this second argument can be omitted, in which case
emails will be sent to dispatch+foo_vcs@tracker.debian.org).
* list_projects.sh pkg-baz
Lists on stdout all the projects of the group pkg-baz, one project per line.
The list will contain at least public projects, and also private projects to
which the token gives access to.
In order to use these scripts, you must create a 'salsarc' file with the
following content:
......
#!/bin/sh
set -e
. ./salsarc
if [ "$#" -ne 1 ] || [ -z "$1" ] ; then
echo "Usage: $0 pkg-baz" >&2
echo " where 'pkg-baz' is the name of the Salsa group for which you want the project list" >&2
exit 1
fi
SALSA_GROUP="$1"
PER_PAGE=100
HEADERS_FILE=$(mktemp)
trap "rm -f $HEADERS_FILE" EXIT
SALSA_GROUP_ID=$(curl --silent -f -XGET --header "PRIVATE-TOKEN: $SALSA_TOKEN" "$SALSA_URL/groups?all_available=false" | jq ".[] | select(.path == \"$SALSA_GROUP\") | .id")
get_one_page ()
{
curl --silent -D $HEADERS_FILE "$SALSA_URL/groups/$SALSA_GROUP_ID/projects?private_token=$SALSA_TOKEN&simple=true&per_page=$PER_PAGE&page=$PAGENO" | jq --raw-output ".[] | .path"
}
PAGENO=1
get_one_page
TOTAL_PAGES=$(grep ^X-Total-Pages: $HEADERS_FILE)
TOTAL_PAGES=${TOTAL_PAGES#*: }
while [ $PAGENO -lt $TOTAL_PAGES ]
do
PAGENO=$((PAGENO+1))
get_one_page
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment