#!/bin/sh -ef

[ -n "$COMFORT_DIR" ] || COMFORT_DIR=/usr/share/comfort
. "$COMFORT_DIR/functions"

# ======================================================================

USAGE='[package-name...]'
DESCRIPTION="
Downloads (clones) whole git repository for given packages from it's
current maintainer."

# Parse command line
. "$COMFORT_DIR/getopt"

# ======================================================================

ensure_ssh_key

for PACKAGE in "$@"; do
	MAINTAINER=`apt-cache show $PACKAGE | sed -ne '/^Maintainer: / { s/^.*<\(.*\)@altlinux.*$/\1/p; q }'`
	Verbose "Cloning package git.alt:/people/$MAINTAINER/packages/$PACKAGE.git"
	git-clone git.alt:/people/$MAINTAINER/packages/$PACKAGE.git "$GIT_HOME_DIR/$PACKAGE"
done
