#!/bin/sh

export LC_ALL=C
repobranch="sisyphus"
while getopts b:h opt; do
	case "$opt" in
		b) repobranch="${OPTARG:?}"
			readonly repobranch ;;
		h) pod2usage --exit=0 "$0"; exit 0 ;;
		*) pod2usage --exit=2 "$0"; exit 2 ;;
	esac
done
shift "$((OPTIND-1))"

name="$1"
if [ -z "$name" ]; then 
    pod2usage --exit=2 "$0"; exit 2;
fi

git ls-remote -h git://git.altlinux.org/gears/${name:0:1}/${name}.git refs/heads/$repobranch | awk '{print $1}'

: <<'__EOF__'

=head1	NAME

girar-print-build-commit - print the last  git.alt:/gears/ build commit for name

=head1	SYNOPSIS

B<girar-print-build-commit>
[B<-h>] 
[B<-b> I<repository>]
I<name>

=head1	DESCRIPTION

B<girar-print-build-commit> 
girar-print-build-commit print the last build commit for I<name>
in git.alt:/gears/../name.git repository for Sisyphus or specified branch.

=head1	OPTIONS

=over

=item	B<-b> I<repository branch>

Name of the repository branch. Values: sisyphus|p6|t6|5.1|..
Default is sisyphus.

=item	B<-h>

Display this help and exit.

=back

=head1	AUTHOR

Written by Igor Vlasenko <viy@altlinux.org>.

=head1	COPYING

Copyright (c) 2011 Igor Vlasenko, ALT Linux Team.

This is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

=cut

__EOF__
