Skip to content

Instantly share code, notes, and snippets.

@k12u
Created August 9, 2011 12:06
Show Gist options
  • Save k12u/1133871 to your computer and use it in GitHub Desktop.
Save k12u/1133871 to your computer and use it in GitHub Desktop.
svn copy helper
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Std;
my %opts;
Getopt::Std::getopts('b:t:', \%opts);
my $svn_info = `svn info|grep URL`;
die "not http repository: $svn_info" unless $svn_info =~ /^URL: https?.+$/sm;
die "trunk/branches directory not found in svn info: $svn_info" unless $svn_info =~ m#^URL: https?.+/(branches|tags|trunk)#sm;
my ($root_path) = (($svn_info =~ m#^URL: (https?.+/)(branches|tags|trunk).*$#sm)[0]);
printf("svn copy %s %s\n", ($root_path . "trunk"), ($root_path . "branches/" . $opts{b})) if($opts{b});
printf("svn copy %s %s\n", ($root_path . "trunk"), ($root_path . "tags/" . $opts{t})) if($opts{t});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment