Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 4 commits
  • 9 files changed
  • 0 commit comments
  • 2 contributors
Commits on Mar 21, 2013
@sitaramc new command 'owns' (thanks to Kevin Pulo) 09e3a3c
@sitaramc DEFAULT_ROLE_PERMS replaced by per repo 'default.roles' option 0419d99
Commits on Mar 24, 2013
@jefferai jefferai overwrite projects.list atomically
avoids any potential race conditions between triggers being run
concurrently, and probably avoids gitweb picking up a half-done file too
289b19d
@sitaramc v3.5 4071623
View
8 CHANGELOG
@@ -1,3 +1,11 @@
+2013-03-24 v3.5 (2 minor backward compat breakages)
+ 1. 'DEFAULT_ROLE_PERMS' replaced by per repo
+ 'default.roles' option
+ 2. 'gitolite list-memberships' now requires a '-r' or a
+ '-u' flag
+
+ new 'gitolite owns' command (thanks to Kevin Pulo)
+
2013-03-05 v3.4 new rc file format makes it much easier to enable specific
features
View
6 src/commands/fork
@@ -44,12 +44,6 @@ echo "$from forked to $to" >&2
cd $GL_REPO_BASE/$to.git
echo $GL_USER > gl-creator
-touch gl-perms
-if gitolite query-rc -q DEFAULT_ROLE_PERMS
-then
- gitolite query-rc DEFAULT_ROLE_PERMS > gl-perms
-fi
-
ln -sf `gitolite query-rc GL_ADMIN_BASE`/hooks/common/* hooks
# record where you came from
View
22 src/commands/owns
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use lib $ENV{GL_LIBDIR};
+use Gitolite::Easy;
+
+=for usage
+Usage: gitolite owns <reponame>
+
+Checks if $GL_USER is an owner of the repo and returns an exit code (shell
+truth, 0 for success), which makes it possible to do this in shell:
+
+ if gitolite owns someRepo
+ then
+ ...
+=cut
+
+usage() if not @ARGV or $ARGV[0] eq '-h';
+my $repo = shift;
+
+exit not owns($repo);
View
1 src/lib/Gitolite/Conf/Store.pm
@@ -191,7 +191,6 @@ sub new_wild_repo {
trigger( 'PRE_CREATE', $repo, $user, $aa );
new_repo($repo);
_print( "$repo.git/gl-creator", $user );
- _print( "$repo.git/gl-perms", ( $rc{DEFAULT_ROLE_PERMS} ? "$rc{DEFAULT_ROLE_PERMS}\n" : "" ) );
trigger( 'POST_CREATE', $repo, $user, $aa );
_chdir( $rc{GL_ADMIN_BASE} );
View
4 src/lib/Gitolite/Easy.pm
@@ -124,8 +124,8 @@ sub in_role {
# return true if $ENV{GL_USER} is set and is an OWNER of the given repo.
-# shell equivalent
-# if gitolite creator $REPONAME $GL_USER; then ...
+# shell equivalent (assuming GL_USER is set)
+# if gitolite owns $REPONAME; then ...
sub owns {
valid_user();
my $r = shift;
View
7 src/lib/Gitolite/Rc.pm
@@ -405,6 +405,8 @@ BEGIN { $non_core = "
ssh-authkeys POST_COMPILE post-compile/ssh-authkeys
Shell POST_COMPILE post-compile/ssh-authkeys-shell-users
+ set-default-roles POST_CREATE .
+
git-config POST_COMPILE post-compile/update-git-configs
git-config POST_CREATE post-compile/update-git-configs
@@ -458,8 +460,6 @@ __DATA__
READERS => 1,
WRITERS => 1,
},
- # uncomment (and change) this if you wish
- # DEFAULT_ROLE_PERMS => 'READERS @all',
# ------------------------------------------------------------------
@@ -535,6 +535,9 @@ __DATA__
# give some users direct shell access
# 'Shell',
+ # set default roles from lines like 'option default.roles-1 = ...', etc.
+ # 'set-default-roles',
+
# system admin stuff
# enable mirroring (don't forget to set the HOSTNAME too!)
View
6 src/triggers/post-compile/update-gitweb-access-list
@@ -20,10 +20,10 @@
plf=`gitolite query-rc GITWEB_PROJECTS_LIST`
[ -z "$plf" ] && plf=$HOME/projects.list
-
+tmpfile=`mktemp $plf.tmp_XXXXXXXX`
(
gitolite list-phy-repos | gitolite access % gitweb R any | grep -v DENIED
gitolite list-phy-repos | gitolite git-config -r % gitweb\\.
) |
- cut -f1 | sort -u | sed -e 's/$/.git/' > $plf
-
+ cut -f1 | sort -u | sed -e 's/$/.git/' > $tmpfile
+mv $tmpfile $plf
View
14 src/triggers/set-default-roles
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# POST_CREATE trigger to set up default set of perms for a new wild repo
+
+# ----------------------------------------------------------------------
+# skip if arg-1 is POST_CREATE and no arg-3 (user name) exists (i.e., it's not
+# a wild repo)
+[ "$1" = "POST_CREATE" ] && [ -z "$3" ] && exit 0;
+
+die() { echo "$@" >&2; exit 1; }
+
+cd $GL_REPO_BASE/$2.git || die "could not cd to $GL_REPO_BASE/$2.git"
+gitolite git-config -r $2 gitolite-options.default.roles | sort | cut -f3 |
+ perl -pe 's/(\s)CREATOR(\s|$)/$1$ENV{GL_USER}$2/' > gl-perms
View
24 t/fork.t
@@ -5,11 +5,12 @@ use warnings;
# this is hardcoded; change it if needed
use lib "src/lib";
use Gitolite::Test;
+my $h = $ENV{HOME};
# fork command
# ----------------------------------------------------------------------
-try "plan 30";
+try "plan 38";
my $rb = `gitolite query-rc -n GL_REPO_BASE`;
@@ -34,7 +35,23 @@ try "
# allow fork as a valid command
$ENV{G3T_RC} = "$ENV{HOME}/g3trc";
-put "$ENV{G3T_RC}", "\$rc{COMMANDS}{fork} = 1;\n\$rc{DEFAULT_ROLE_PERMS} = 'READERS \@all';\n";
+put "$ENV{G3T_RC}", "\$rc{COMMANDS}{fork} = 1;\n";
+
+# enable set-default-roles feature, add options, push
+try "
+ cat $h/.gitolite.rc
+ perl s/# 'set-default-roles'/'set-default-roles'/
+ put $h/.gitolite.rc
+";
+try "cd gitolite-admin";
+confadd '
+ repo foo/CREATOR/..*
+ C = u1 u2
+ RW+ = CREATOR
+ option default.roles-1 = READERS @all
+';
+try "ADMIN_PUSH set1; !/FATAL/" or die text();
+try "cd ..";
try "
# now the fork succeeds
@@ -61,8 +78,7 @@ try "
my $t;
try "cd $rb; find . -name gl-perms"; $t = md5sum(sort (lines())); cmp $t,
-'d41d8cd98f00b204e9800998ecf8427e ./foo/u1/u1a.git/gl-perms
-59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1a2.git/gl-perms
+'59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1a2.git/gl-perms
59b3a74b4d33c7631f08e75e7b60c7ce ./foo/u1/u1e.git/gl-perms
';

No commit comments for this range

Something went wrong with that request. Please try again.