2012-03-21 03:19:13 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Usage: ssh git@host desc <repo>
|
|
|
|
# ssh git@host desc <repo> <description string>
|
|
|
|
#
|
|
|
|
# Show or set description for user-created ("wild") repo.
|
|
|
|
|
|
|
|
die() { echo "$@" >&2; exit 1; }
|
|
|
|
usage() { perl -lne 'print substr($_, 2) if /^# Usage/../^$/' < $0; exit 1; }
|
|
|
|
[ -z "$1" ] && usage
|
|
|
|
[ "$1" = "-h" ] && usage
|
|
|
|
[ -z "$GL_USER" ] && die GL_USER not set
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------
|
|
|
|
repo=$1; shift
|
|
|
|
|
|
|
|
# this shell script takes arguments that are completely under the user's
|
|
|
|
# control, so make sure you quote those suckers!
|
2012-03-22 10:15:30 +01:00
|
|
|
|
|
|
|
# kernel.org needs 'desc' to be available to people who have "RW" or above,
|
|
|
|
# not just the "creator". In fact they need it for non-wild repos so there
|
|
|
|
# *is* no creator.
|
|
|
|
if gitolite query-rc -q WRITER_CAN_UPDATE_DESC
|
|
|
|
then
|
|
|
|
gitolite access -q "$repo" $GL_USER W any || die You are not authorised
|
|
|
|
else
|
|
|
|
gitolite creator "$repo" $GL_USER || die You are not authorised
|
|
|
|
fi
|
|
|
|
|
2012-03-21 05:04:39 +01:00
|
|
|
# if it passes, $repo is a valid repo name so it is known to contain only sane
|
|
|
|
# characters. This is because 'gitolite creator' return true only if there
|
|
|
|
# *is* a repo of that name and it has a gl-creator file that contains the same
|
|
|
|
# text as $GL_USER.
|
|
|
|
|
2012-03-21 03:19:13 +01:00
|
|
|
descfile=`gitolite query-rc GL_REPO_BASE`/"$repo".git/description
|
|
|
|
|
|
|
|
if [ -z "$1" ]
|
|
|
|
then
|
2012-03-21 05:04:39 +01:00
|
|
|
[ -r "$descfile" ] && cat "$descfile"
|
2012-03-21 03:19:13 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2012-03-21 05:04:39 +01:00
|
|
|
echo "$*" > "$descfile"
|