diff options
author | Andy Doan <andy.doan@linaro.org> | 2016-08-24 12:04:31 -0500 |
---|---|---|
committer | Andy Doan <andy.doan@linaro.org> | 2016-08-24 12:04:31 -0500 |
commit | f7127b9e52db779f7d04f9ed099358e360c7bad2 (patch) | |
tree | f14e05f8d4cdfdd2e499a5278fc7287c7c9127b6 | |
parent | 59540889ae92ea8e45661dfee9e48fe19bcd78bc (diff) |
add gitolite-can-read helper
As per: https://review.linaro.org/#/c/13634
We need an easy way to determine if a user has read access to repo.
Change-Id: I3f66dcc4a14801bbc5db8d446e9a737b53d1c76b
-rw-r--r-- | gitolite-tools/gitolite-can-read | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gitolite-tools/gitolite-can-read b/gitolite-tools/gitolite-can-read new file mode 100644 index 0000000..331c60f --- /dev/null +++ b/gitolite-tools/gitolite-can-read @@ -0,0 +1,20 @@ +#!/usr/bin/perl +BEGIN { + $ENV{HOME} = "/home/git"; + $ENV{GL_LIBDIR} = "/home/git/gitolite/src/lib"; +}; +# Pull in gitolite's perl API module. Among other things, this also sets the +# GL_REPO_BASE environment variable. +use lib $ENV{GL_LIBDIR}; +use Gitolite::Easy; +if ($#ARGV != 1) { + print "Usage: $0 <user> <repo>\n"; + exit 1; +} +if (getpwuid($<) ne "git") { + print "This command must be run as the 'git user'\n"; + exit 1; +} + +$ENV{GL_USER} = $ARGV[0]; +exit !can_read($ARGV[1]); |