aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSitaram Chamarty <sitaram@atc.tcs.com>2016-06-07 09:16:17 +0530
committerSitaram Chamarty <sitaram@atc.tcs.com>2016-06-07 10:25:53 +0530
commit753099620aa35434fffada66d9e862d0a8468d63 (patch)
tree3097f941f312013606376ad3fbfa8e1368782d23
parentrewrite create command (diff)
downloadgitolite-gentoo-753099620aa35434fffada66d9e862d0a8468d63.tar.gz
gitolite-gentoo-753099620aa35434fffada66d9e862d0a8468d63.tar.bz2
gitolite-gentoo-753099620aa35434fffada66d9e862d0a8468d63.zip
perms: make '-c' required for batch mode
quoth Tony: > Typing ^C at a command to make it stop without doing anything is a natural > reaction, regardless of any imprecations to type "cancel" He asked for a '-b' option; i.e., don't allow a bare "ssh git@... perms repo" to be interpreted as batch mode. Meanwhile, '-c' is acceptable for existing repos too (as you can see from the mirroring code at least). So, just think of '-c' as a moral eqvt of '-b' that already exists.
-rwxr-xr-xsrc/commands/perms21
-rwxr-xr-xt/perm-default-roles.t2
-rwxr-xr-xt/perm-roles.t12
-rwxr-xr-xt/perms-groups.t6
-rwxr-xr-xt/sequence.t4
5 files changed, 23 insertions, 22 deletions
diff --git a/src/commands/perms b/src/commands/perms
index 66ae885..be7be69 100755
--- a/src/commands/perms
+++ b/src/commands/perms
@@ -26,23 +26,24 @@ Examples:
ssh git@host perms my/repo + WRITERS bob
----
-There is also a batch mode useful for scripting and bulk loading. Do not
-combine this with the +/- mode above. This mode also accepts an optional "-c"
-flag to create the repo if it does not already exist (assuming $GL_USER has
-permissions to create it).
-
-Examples:
- cat copy-of-backed-up-gl-perms | ssh git@host perms <repo>
- cat copy-of-backed-up-gl-perms | ssh git@host perms -c <repo>
+There is also a batch mode useful for scripting and bulk loading; see the
+source code of the perms command for details.
=cut
-usage() if not @ARGV or $ARGV[0] eq '-h';
+# BATCH MODE: DO NOT combine this with the +/- mode above. This mode also
+# creates the repo if it does not already exist (assuming $GL_USER has
+# permissions to create it).
+#
+# Example:
+# cat copy-of-backed-up-gl-perms | ssh git@host perms -c <repo>
+
+usage() if not @ARGV or $ARGV[0] eq '-h' or @ARGV < 2;
$ENV{GL_USER} or _die "GL_USER not set";
my $generic_error = "repo does not exist, or you are not authorised";
-if ( @ARGV >= 2 and $ARGV[1] eq '-l' ) {
+if ( $ARGV[1] eq '-l' ) {
getperms($ARGV[0]); # doesn't return
}
diff --git a/t/perm-default-roles.t b/t/perm-default-roles.t
index 1a56ff8..c417903 100755
--- a/t/perm-default-roles.t
+++ b/t/perm-default-roles.t
@@ -139,7 +139,7 @@ try "cd $od";
# add perms to an old repo
try "
-echo WRITERS \@h1 | glt perms u1 foo/u1/u1r1
+echo WRITERS \@h1 | glt perms u1 -c foo/u1/u1r1
";
try "cd $rb; find . -name gl-perms";
diff --git a/t/perm-roles.t b/t/perm-roles.t
index 03403d6..c4d017f 100755
--- a/t/perm-roles.t
+++ b/t/perm-roles.t
@@ -63,7 +63,7 @@ glt push u1 file:///foo/u1/u1r1 t1
POK; /\\[new tag\\] t1 -> t1/
# add u2 to WRITERS
-echo WRITERS \@g2 | glt perms u1 foo/u1/u1r1
+echo WRITERS \@g2 | glt perms u1 -c foo/u1/u1r1
glt perms u1 foo/u1/u1r1 -l
/WRITERS \@g2/
@@ -95,7 +95,7 @@ glt push u2 file:///foo/u1/u1r1 t2
reject
# change u2 to READERS
-echo READERS u2 | glt perms u1 foo/u1/u1r1
+echo READERS u2 | glt perms u1 -c foo/u1/u1r1
glt perms u1 foo/u1/u1r1 -l
/READERS u2/
@@ -108,7 +108,7 @@ glt push u2 file:///foo/u1/u1r1 master:master
/W any foo/u1/u1r1 u2 DENIED by fallthru/
# add invalid category MANAGERS
- /usr/bin/printf 'READERS u6\\nMANAGERS u2\\n' | glt perms u1 foo/u1/u1r1
+ /usr/bin/printf 'READERS u6\\nMANAGERS u2\\n' | glt perms u1 -c foo/u1/u1r1
!ok
/Invalid role 'MANAGERS'/
";
@@ -120,7 +120,7 @@ put "$ENV{HOME}/g3trc", "\$rc{ROLES}{MANAGERS} = 1;\n";
try "
ENV G3T_RC=$ENV{HOME}/g3trc
gitolite compile; ok or die compile failed
- /usr/bin/printf 'READERS u6\\nMANAGERS u2\\n' | glt perms u1 foo/u1/u1r1
+ /usr/bin/printf 'READERS u6\\nMANAGERS u2\\n' | glt perms u1 -c foo/u1/u1r1
ok; !/Invalid role 'MANAGERS'/
glt perms u1 foo/u1/u1r1 -l
";
@@ -156,7 +156,7 @@ glt push u2 file:///foo/u1/u1r1 t3
POK; /\\[new tag\\] t3 -> t3/
# add invalid category TESTERS
-echo TESTERS u2 | glt perms u1 foo/u1/u1r1
+echo TESTERS u2 | glt perms u1 -c foo/u1/u1r1
!ok
/Invalid role 'TESTERS'/
";
@@ -167,7 +167,7 @@ put "|cat >> $ENV{HOME}/g3trc", "\$rc{ROLES}{TESTERS} = 1;\n";
try "
gitolite compile; ok or die compile failed
# add u2 to now valid TESTERS
-echo TESTERS u2 | glt perms u1 foo/u1/u1r1
+echo TESTERS u2 | glt perms u1 -c foo/u1/u1r1
!/Invalid role 'TESTERS'/
glt perms u1 foo/u1/u1r1 -l
";
diff --git a/t/perms-groups.t b/t/perms-groups.t
index 5de75be..eb51bc7 100755
--- a/t/perms-groups.t
+++ b/t/perms-groups.t
@@ -41,7 +41,7 @@ try "
!/R W *\tbar/u1/try1\tu1/
# \@leads can RW try1
- echo WRITERS \@leads | glt perms u1 bar/u1/try1; ok
+ echo WRITERS \@leads | glt perms u1 -c bar/u1/try1; ok
glt info u1 -lc
/R W *\tbar/u1/try1\tu1/
glt info u2 -lc
@@ -50,7 +50,7 @@ try "
!/R W *\tbar/u1/try1\tu1/
# \@devs can R try1
- echo READERS \@devs | glt perms u1 bar/u1/try1; ok
+ echo READERS \@devs | glt perms u1 -c bar/u1/try1; ok
glt perms u1 bar/u1/try1 -l
/READERS \@devs/
!/WRITERS \@leads/
@@ -67,7 +67,7 @@ try "
/R *\tbar/u1/try1\tu1/
# combo of previous 2
- /usr/bin/printf 'READERS \@devs\\nWRITERS \@leads\\n' | glt perms u1 bar/u1/try1; ok
+ /usr/bin/printf 'READERS \@devs\\nWRITERS \@leads\\n' | glt perms u1 -c bar/u1/try1; ok
glt perms u1 bar/u1/try1 -l
/READERS \@devs/
/WRITERS \@leads/
diff --git a/t/sequence.t b/t/sequence.t
index 81fabfc..8d66d03 100755
--- a/t/sequence.t
+++ b/t/sequence.t
@@ -33,7 +33,7 @@ try "
glt push u1 origin master
/To file:///foo/u1/bar/
/\\[new branch\\] master -> master/
- echo WRITERS u2 | glt perms u1 foo/u1/bar
+ echo WRITERS u2 | glt perms u1 -c foo/u1/bar
glt perms u1 foo/u1/bar -l
/WRITERS u2/
# expand
@@ -77,7 +77,7 @@ try "
glt push u1 origin master
/To file:///foo/u1/bar/
/\\[new branch\\] master -> master/
- echo WRITERS u2 | glt perms u1 foo/u1/bar
+ echo WRITERS u2 | glt perms u1 -c foo/u1/bar
glt perms u1 foo/u1/bar -l
/WRITERS u2/
# expand