diff options
author | Markus Mayer <code@mmayer.net> | 2014-02-03 11:45:56 -0800 |
---|---|---|
committer | Sitaram Chamarty <sitaram@atc.tcs.com> | 2014-02-04 07:32:05 +0530 |
commit | 249916ca64468a8342dd95a3cbed43a3825202b6 (patch) | |
tree | 71a3279aec01bd56a7da2e7a90b05c3d88981b27 | |
parent | fc5467c76da69c8977b8869c59aa672a7a576fdb (diff) |
Add "readme" command to gitolite
The "readme" command allows users of wild repos to view, add or remove
a README.html page.
The code is largely modelled after the "desc" script.
-rwxr-xr-x | src/commands/readme | 45 | ||||
-rw-r--r-- | src/lib/Gitolite/Rc.pm | 3 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/commands/readme b/src/commands/readme new file mode 100755 index 0000000..358ce3e --- /dev/null +++ b/src/commands/readme @@ -0,0 +1,45 @@ +#!/bin/sh + +# README.html files work similar to "description" files. For further +# information see +# https://www.kernel.org/pub/software/scm/git/docs/gitweb.html +# under "Per-repository gitweb configuration". + +# Usage: ssh git@host readme <repo> +# ssh git@host readme <repo> rm +# cat <filename> | ssh git@host readme <repo> set +# +# Show, remove or set the README.html file 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 +[ $# -gt 1 ] && [ "$2" != "set" ] && [ "$2" != "rm" ] && usage +[ -z "$GL_USER" ] && die GL_USER not set + +# ---------------------------------------------------------------------- +repo=$1; shift + +if gitolite query-rc -q WRITER_CAN_UPDATE_README +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 + +readmefile=`gitolite query-rc GL_REPO_BASE`/"$repo".git/README.html + +if [ -z "$1" ] +then + [ -r "$readmefile" ] && cat "$readmefile" + exit 0 +fi + +if [ "$1" = "rm" ] +then + rm -f "$readmefile" + exit 0 +fi + +cat >"$readmefile" diff --git a/src/lib/Gitolite/Rc.pm b/src/lib/Gitolite/Rc.pm index 9b15f23..3d1af57 100644 --- a/src/lib/Gitolite/Rc.pm +++ b/src/lib/Gitolite/Rc.pm @@ -482,6 +482,8 @@ __DATA__ # the 'desc' command uses this # WRITER_CAN_UPDATE_DESC => 1, + # the 'readme' command uses this + # WRITER_CAN_UPDATE_README => 1, # the CpuTime feature uses these # display user, system, and elapsed times to user after each git operation @@ -526,6 +528,7 @@ __DATA__ # 'create', # 'fork', # 'mirror', + # 'readme', # 'sskm', # 'D', |