updated git and svn scripts
[xrzperl.git] / gsvn-push
blob422f782f4bf738693f5356759a20ae0e4cfc0149
1 #!/usr/bin/perl -w
2 # $Id$
3 use strict;
4 require v5.10.0;
5 our $VERSION = 'v0.1';
7 sub push_remote {
8 my @remotes;
9 open FI,"-|","git remote";
10 while(<FI>) {
11 chomp;
12 push @remotes,$_ if($_);
14 close FI;
15 if(@remotes) {
16 foreach(@remotes) {
17 my $url = `git config --get "remote.$_.url"`;
18 chomp($url);
19 #print "pushing to [$_] $url ...\n";
20 if(system(qw/git push -v/,$_)==0) {
21 # return 1;
23 else {
24 print "pushing to $_ failed\n";
25 return undef;
28 return 1;
30 else {
31 print "NO remotes found, stop pushing\n";
32 return undef;
36 my $NEED_COMMIT = `git diff`;
37 chomp($NEED_COMMIT);
38 my $idx = 1;
39 my $total = 3;
40 #$NEED_COMMIT ? 3 : 2;
42 print "[$idx/$total] git commit ", (@ARGV ? join(" ",@ARGV) : ""), "\n";
43 if($NEED_COMMIT) {
44 if (system(qw/git commit/,@ARGV) != 0) {
45 die "[$idx/$total] git commit failed\n";
48 else {
49 system(qw/git commit/,@ARGV);
51 $idx++;
54 print "[$idx/$total] git svn dcommit\n";
55 if(system(qw/git svn dcommit/) != 0) {
56 die "[$idx/$total] git svn dcommit failed\n";
58 $idx++;
61 print "[$idx/$total] git push --all [remotes]\n";
62 #system(qw/git remote -v/);
63 if(!push_remote()) {
64 die "[$idx/$total] git push --all [remotes] failed\n";
66 $idx++;
69 exit 0;
73 __END__
75 =pod
77 =head1 NAME
79 git-svn-push - PERL script
81 =head1 SYNOPSIS
83 git-svn-push [options] ...
85 =head1 OPTIONS
87 =over 12
89 =item B<--version>
91 Print version infomation.
93 =item B<-h>,B<--help>
95 Print a brief help message and exits.
97 =item B<--manual>,B<--man>
99 View application manual
101 =item B<--edit-me>
103 Invoke 'editor' against the source
105 =back
107 =head1 DESCRIPTION
109 ___DESC___
111 =head1 CHANGELOG
113 2010-10-31 xiaoranzzz <xiaoranzzz@myplace.hell>
115 * file created.
117 =head1 AUTHOR
119 xiaoranzzz <xiaoranzzz@myplace.hell>
121 =cut
123 # vim:filetype=perl