aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2016-04-12 10:32:20 +0200
committerSitaram Chamarty <sitaram@atc.tcs.com>2016-05-19 14:28:01 +0530
commitd4980d1e56c145df43acfa971ad77a8d485432d0 (patch)
tree90b4eba0768c79381fb157466af52181584b6ea0
parentdon't run postupdate unless master has been pushed (diff)
downloadgitolite-gentoo-d4980d1e56c145df43acfa971ad77a8d485432d0.tar.gz
gitolite-gentoo-d4980d1e56c145df43acfa971ad77a8d485432d0.tar.bz2
gitolite-gentoo-d4980d1e56c145df43acfa971ad77a8d485432d0.zip
rewrite create command
create no longer calls the perms command, but creates the repo itself. There is some code duplication, but less dependencies between the commands. (With minor modifications by committer)
-rwxr-xr-xsrc/commands/create46
-rwxr-xr-xsrc/triggers/set-default-roles2
2 files changed, 30 insertions, 18 deletions
diff --git a/src/commands/create b/src/commands/create
index d35c4a8..8565e68 100755
--- a/src/commands/create
+++ b/src/commands/create
@@ -1,17 +1,29 @@
-#!/bin/sh
-
-# Usage: ssh git@host create <repo>
-#
-# Create wild repo.
-
-die() { echo "$@" >&2; exit 1; }
-usage() { perl -lne 'print substr($_, 2) if /^# Usage/../^$/' < $0; exit 1; }
-[ -z "$1" ] && usage
-[ -z "$2" ] || usage
-[ "$1" = "-h" ] && usage
-[ -z "$GL_USER" ] && die GL_USER not set
-
-# ----------------------------------------------------------------------
-perms=$(gitolite git-config -r $1 gitolite-options.default.roles | sort | cut -f3 |
- perl -pe 's/(\s)CREATOR(\s|$)/$1$ENV{GL_USER}$1/')
-echo "$perms" | $GL_BINDIR/commands/perms -c "$@"
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+use lib $ENV{GL_LIBDIR};
+use Gitolite::Rc;
+use Gitolite::Common;
+use Gitolite::Conf::Load;
+use Gitolite::Conf::Store;
+
+=for usage
+create -- create a wild repo.
+
+Usage:
+ ssh git@host create <repo>
+=cut
+
+usage() if @ARGV != 1 or $ARGV[0] eq '-h';
+
+$ENV{GL_USER} or _die "GL_USER not set";
+
+my $repo = shift;
+_die "invalid repo '$repo'" unless $repo =~ $REPONAME_PATT;
+
+my $ret = access( $repo, $ENV{GL_USER}, '^C', 'any' );
+_die "repo already exists or you are not authorised to create it" if $ret =~ /DENIED/;
+
+new_wild_repo( $repo, $ENV{GL_USER}, 'create' );
+gl_log( 'create', $repo, $ENV{GL_USER}, 'create' );
diff --git a/src/triggers/set-default-roles b/src/triggers/set-default-roles
index 18ac28b..dbbcc92 100755
--- a/src/triggers/set-default-roles
+++ b/src/triggers/set-default-roles
@@ -6,7 +6,7 @@
# 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;
-[ "$4" = "R" ] || [ "$4" = "W" ] || [ "$4" = "perms-c" ] || [ "$4" = "fork" ] || exit 0
+[ "$4" = "R" ] || [ "$4" = "W" ] || [ "$4" = "perms-c" ] || [ "$4" = "create" ] || [ "$4" = "fork" ] || exit 0
die() { echo "$@" >&2; exit 1; }