#!/bin/sh
# usage (over ssh, as the git user): ssh git@<host> describe <reponame> <text...>
#
# Sets the repo's description -- the standard git `description` file inside
# the bare repo, same mechanism cgit/gitweb/stagit all read. foxygit shows it
# on the repo index and in an "about" box at the top of the repo's pages.
# Paths below must match server/setup-server.sh.

reposdir="/var/git/repos"

name="$1"
if [ -z "$name" ]; then
	echo "usage: describe <reponame> <description text>" >&2
	exit 1
fi
shift

name=$(basename "$name" ".git")
case "$name" in
	*/* | .* | -*)
		echo "invalid repo name: $name" >&2
		exit 1
		;;
esac

dest="${reposdir}/${name}.git"
if [ ! -d "$dest" ]; then
	echo "no such repo: ${name}.git" >&2
	exit 1
fi

if [ -z "$1" ]; then
	echo "usage: describe <reponame> <description text>" >&2
	exit 1
fi

echo "$*" > "${dest}/description"
echo "description set for ${name}.git"
