Commit ffca05e1 authored by Mehdi Dogguy's avatar Mehdi Dogguy

second parameter for emails_on_push.sh should be optional

parent 16831c18
#!/bin/sh
set -eu
set -e
. ./salsarc
if [ "$#" -ne 2 ] || [ -z "$1" ]; then
if [ "$#" -ne 1 ] || [ -z "$1" ]; then
echo "Usage: $0 foo [recipient ...]" >&2
echo " where 'foo' is the Salsa project name for which you want to setup email notifications for [recipients]." >&2
echo " If recipients is empty, then this script will use 'dispatch+foo_vcs@tracker.debian.org'" >&2
......@@ -12,7 +12,11 @@ if [ "$#" -ne 2 ] || [ -z "$1" ]; then
fi
PROJECT_NAME="$1"
RECIPIENTS="$2"
if [ -z "$2" ]; then
RECIPIENTS="dispatch+${PROJECT_NAME}_vcs@tracker.debian.org"
else
RECIPIENTS="$2"
fi
PROJECT_ID=$(curl --silent -f -XGET --header "PRIVATE-TOKEN: $SALSA_TOKEN" $SALSA_URL/v3/projects/owned | jq ".[] | select(.name == \"$PROJECT_NAME\") | .id")
if [ -z "$PROJECT_ID" ]; then
......@@ -22,10 +26,6 @@ else
echo "Setting up emails_on_push service for $PROJECT_NAME ($PROJECT_ID)"
fi
if [ -z "$RECIPIENTS" ]; then
RECIPIENTS="dispatch+${PROJECT_NAME}_vcs@tracker.debian.org"
fi
case $PROJECT_ID in
''|*[!0-9]*) echo "$PROJECT_NAME not found using $SALSA_URL service" ;;
*) curl -XPUT --header "PRIVATE-TOKEN: $SALSA_TOKEN" \
......
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