#!/bin/bash
task_id=$1

echo "$tag $repo"

if [ -z "$2" ]; then
    tag=`git describe --abbrev=0 `
    repo=`git config --get remote.origin.url | sed 's!^.*:packages/!!'`
elif [ -z "$3" ]; then
    tag=$1
    repo=${tag%%/*}
else
    repo=$1
    tag=$2
fi

echo "tag: $tag"
echo "repo: $repo"

if [ -z "$task_id" ]; then
    git.alt task add repo "$repo" "$tag" \
		2>&1 \
		| csed '/not\ found/ p red,bold'
else
    git.alt task add "$task_id" repo "$repo" "$tag" \
		2>&1 \
		| csed '/not\ found/ p red,bold'
fi

exit $?

