#!/bin/sh

start_commit() {
	local repo_path="$1"
	local user="$2"
	local repo="`basename "${repo_path}"`"

	ans="`wget -q -O- "%API%/projectHasMember/${repo}/${user}" 2>/dev/null`"
	[ "${ans}" = "YES" ] && return 0;

	[ "${ans}" = "NO" ] && {
		echo "${user} is not a member of ${repo}" >&2
		return 1
	}

	echo "Critical error occurred while checking project membership of ${repo} for ${user}" >&2
	return 1
}

start_commit "$1" "$2"
exit $?
