Update the script to handle git as well as svn repos
This commit was SVN r32598.
Этот коммит содержится в:
родитель
6a3225d800
Коммит
9b95de1b62
@ -38,6 +38,10 @@ my $diff_file = "";
|
||||
my $diff_arg;
|
||||
my $update_arg;
|
||||
my $modified_arg;
|
||||
my $git_arg = 0;
|
||||
my $svn_arg = 0;
|
||||
my $repo_type;
|
||||
my $cmd;
|
||||
|
||||
sub construct {
|
||||
# don't process directories or links, and dont' recurse down
|
||||
@ -84,6 +88,8 @@ my $ok = Getopt::Long::GetOptions("help|h" => \$help_arg,
|
||||
"diff=s" => \$diff_arg,
|
||||
"update" => \$update_arg,
|
||||
"update-modified" => \$modified_arg,
|
||||
"git" => \$git_arg,
|
||||
"svn" => \$svn_arg
|
||||
);
|
||||
|
||||
if (!$ok || $help_arg) {
|
||||
@ -94,7 +100,9 @@ if (!$ok || $help_arg) {
|
||||
--src | -src Head of source directory
|
||||
--tgt | -tgt Head of target directory
|
||||
--update | -update Apply changes to update target
|
||||
--update-modified Only update modified files (do not add/delete files)\n";
|
||||
--update-modified Only update modified files (do not add/delete files)
|
||||
--git Target is a git repo, so use git commands to add/delete files
|
||||
--svn Target is a svn repo, so use svn commands to add/delete files\n";
|
||||
exit($ok ? 0 : 1);
|
||||
}
|
||||
|
||||
@ -103,6 +111,16 @@ if (!$src_arg || !$tgt_arg) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!$git_arg && !$svn_arg) {
|
||||
print "Missing repo type argument\n";
|
||||
exit(1);
|
||||
}
|
||||
if ($git_arg) {
|
||||
$repo_type = 1;
|
||||
} else {
|
||||
$repo_type = 0;
|
||||
}
|
||||
|
||||
$src_dir = File::Spec->rel2abs($src_arg);
|
||||
$target_dir = File::Spec->rel2abs($tgt_arg);
|
||||
my @srcpth = ();
|
||||
@ -209,13 +227,21 @@ foreach $src (@src_tree) {
|
||||
print "Failed to create path $tpath\n";
|
||||
exit;
|
||||
}
|
||||
print "Adding $tpath to svn repo\n";
|
||||
my $cmd = "svn add $tpath";
|
||||
print "Adding $tpath to repo\n";
|
||||
if (1 == $repo_type) {
|
||||
$cmd = "pushd $target_dir >& /dev/null; git add $tpath >& /dev/null; popd >& /dev/null";
|
||||
} else {
|
||||
$cmd = "pushd $target_dir >& /dev/null; svn add $tpath >& /dev/null; popd >& /dev/null";
|
||||
}
|
||||
system($cmd);
|
||||
}
|
||||
print "Copying $src to $targetpath\n";
|
||||
print "Adding $src to repo\n";
|
||||
copy("$src", "$targetpath") or die "Update failed: src=$src tgt=$targetpath\n";
|
||||
my $cmd = "svn add $targetpath";
|
||||
if (1 == $repo_type) {
|
||||
$cmd = "pushd $target_dir >& /dev/null; git add $targetpath >& /dev/null; popd >& /dev/null";
|
||||
} else {
|
||||
$cmd = "pushd $target_dir >& /dev/null; svn add $targetpath >& /dev/null; popd >& /dev/null";
|
||||
}
|
||||
system($cmd);
|
||||
} else {
|
||||
print "Add: " . $src . "\n";
|
||||
@ -242,7 +268,12 @@ if (!$modified_arg) {
|
||||
}
|
||||
if ($found == 0) {
|
||||
if ($update_arg) {
|
||||
my $cmd = "svn del $tgt";
|
||||
print "Removing $tgt_file from repo\n";
|
||||
if (1 == $repo_type) {
|
||||
$cmd = "pushd $target_dir >& /dev/null; git rm .$tgt_file >& /dev/null; popd >& /dev/null";
|
||||
} else {
|
||||
$cmd = "pushd $target_dir >& /dev/null; svn del $tgt >& /dev/null; popd >& /dev/null";
|
||||
}
|
||||
system($cmd);
|
||||
} else {
|
||||
print "Delete: " . $tgt . "\n";
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user