updated git and svn scripts
[xrzperl.git] / gsvn-clone
blobb58b2d2fd918baf2da76dce0e894cde6f59c854d
1 #!/usr/bin/perl -w
2 # $Id$
3 use strict;
4 require v5.10.0;
5 our $VERSION = 'v0.1';
7 BEGIN
9 my $PROGRAM_DIR = $0;
10 $PROGRAM_DIR =~ s/[^\/\\]+$//;
11 $PROGRAM_DIR = "./" unless($PROGRAM_DIR);
12 unshift @INC,
13 map "$PROGRAM_DIR$_",qw{modules lib ../modules ..lib};
16 my %OPTS;
17 my @OPTIONS = qw/help|h|? version|ver edit-me manual|man/;
19 if(@ARGV)
21 require Getopt::Long;
22 require MyPlace::Usage;
23 Getopt::Long::GetOptions(\%OPTS,@OPTIONS);
24 MyPlace::Usage::Process(\%OPTS,$VERSION);
26 else
28 require MyPlace::Usage;
29 MyPlace::Usage::PrintHelp();
32 my $url = shift;
33 my $target = shift;
34 if(!$target) {
35 die("Usage: $0 svn_repo_url target\n");
38 my $authors;
39 foreach my $fn ("authors",".authors","~/gsvn/authors","~/.authors") {
40 if( -f $fn) {
41 $authors = $fn;
42 last;
44 elsif(-f "$fn.txt") {
45 $authors = "$fn.txt";
46 last;
50 if(!($authors and -f $authors)) {
51 die("NO authors file found\n");
53 print "[1/2] cloning $url to [$target] ...\n";
54 if(system(qw/git svn clone -s -A/,$authors,$url,$target,@ARGV) != 0) {
55 die("fatal: while clone $url to [$target]\n");
57 print "[2/2] init repos of [$target] ...\n";
58 if(system("gsvn-init-repos",$target)!=0) {
59 die("fatal: while init repos of [$target]\n");
61 exit 0;
63 __END__
65 =pod
67 =head1 NAME
69 gsvn-clone - PERL script
71 =head1 SYNOPSIS
73 gsvn-clone [options] <svn repo url> [target directory] [git svn clone options...]
75 =head1 OPTIONS
77 =over 12
79 =item B<--version>
81 Print version infomation.
83 =item B<-h>,B<--help>
85 Print a brief help message and exits.
87 =item B<--manual>,B<--man>
89 View application manual
91 =item B<--edit-me>
93 Invoke 'editor' against the source
95 =back
97 =head1 DESCRIPTION
99 ___DESC___
101 =head1 CHANGELOG
103 2010-11-02 xiaoranzzz <xiaoranzzz@myplace.hell>
105 * file created.
107 2010-11-03 xiaoranzzz <xiaoranzzz@myplace.hell>
108 * add usage information
110 =head1 AUTHOR
112 xiaoranzzz <xiaoranzzz@myplace.hell>
114 =cut
116 # vim:filetype=perl