diff options
author | root <root@piny.svcs.cs.pdx.edu> | 2009-09-08 04:17:33 -0700 |
---|---|---|
committer | root <root@piny.svcs.cs.pdx.edu> | 2009-09-08 04:17:33 -0700 |
commit | 94e46bd31b87e0b83e7dd4a9a22a038c7d9d5a33 (patch) | |
tree | ede8e3d406cab5a00d0e0f2c00030e948de4ec1d /usr/local | |
parent | 8f57b985bf4057fdde27c7e7325b74da2f22a267 (diff) | |
download | piny-code-94e46bd31b87e0b83e7dd4a9a22a038c7d9d5a33.tar.gz piny-code-94e46bd31b87e0b83e7dd4a9a22a038c7d9d5a33.zip |
Adding 'description' field support. Not yet sure if I like it being stdin.
Diffstat (limited to 'usr/local')
-rwxr-xr-x | usr/local/sbin/newrepo | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/usr/local/sbin/newrepo b/usr/local/sbin/newrepo index 7c7539b..b903064 100755 --- a/usr/local/sbin/newrepo +++ b/usr/local/sbin/newrepo @@ -4,7 +4,7 @@ use strict; use warnings; my( $errorto ) = 'jrayhawk+piny.svcs.cs.pdx.edu@omgwallhack.org'; # Email address to send horrible errors to. -my( $reponame, $email, @errors, $wikilisttempfile, $cgitrctempfile); +my( $reponame, $email, @errors, $wikilisttempfile, $cgitrctempfile, $description ); if ( ( ! scalar $ARGV[0] ) or ( scalar $ARGV[1] ) or ( $ARGV[0] !~ /^[a-z0-9][a-z0-9+.-]+$/ ) ) { print( "Usage: newrepo REPONAME\n" ); @@ -56,10 +56,24 @@ if( @errors ) { exit( 2 ); }; +while ( 1 ) { + + print( "Provide a one-line description to be used in repo listings, the shorter the better:\n" ); + chomp( $description = <STDIN> ); + + if( $description !~ /^[\x{0020}-\x{FDCF}\x{FDF0}-\x{FFFD}]{1,80}$/ ) { # everything but control characters and unicode-defined non-characters + print( "Must be 1-80 characters long; control characters (including tab) not allowed.\n" ); + next; + }; + + print( "Okay! Working, please wait...\n" ); + last; + +}; # CREATE USER/GROUPS unless( system( "mkdir /srv/git/$reponame.git" ) == 0 ) { # We need a locking or atomic operation as our first to check against simultaneous execution. - print( "I suspect that you are attempting to create the same repo multiple times simultaneously.\n" ); + print( "Somebody else has created the same repo as you in the course of executing this program!" ); exit( 3 ); }; system( "/usr/sbin/addgroup --quiet git-$reponame" ); @@ -70,7 +84,7 @@ system( "/usr/sbin/adduser --quiet $ENV{SUDO_USER} git-$reponame | grep -v 'Addi # CREATE REPO system( "GIT_DIR=/srv/git/$reponame.git /usr/bin/git init --template=/srv/git-template.git --quiet --shared" ); open ( DESC, ">/srv/git/$reponame.git/description" ); -print( DESC "$reponame owned by $email" ); +print( DESC "$description" ); close( DESC ); # ln -f post-receive /srv/git/$reponame.git/hooks/ # turn on e-mail commit notices system( "/bin/chown -R $ENV{SUDO_USER}.git-$reponame /srv/git/$reponame.git/" ); @@ -211,7 +225,7 @@ open ( CGITRC, ">/etc/cgitrc.d/$reponame" ); # Maybe someday cgit will support c print( CGITRC "repo.url=$reponame repo.path=/srv/git/$reponame.git -repo.desc=$reponame +repo.desc=$description repo.owner=$email " ); # In the meantime, we fake it. |