-
Notifications
You must be signed in to change notification settings - Fork 1
/
kill-svn-branch
executable file
·39 lines (33 loc) · 954 Bytes
/
kill-svn-branch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/local/bin/perl
use strict;
use warnings;
use Cwd qw(realpath);
use File::Basename;
my $BASE_DIR = dirname realpath __FILE__;
use File::Path qw(rmtree);
my $GIT_DIR = `git rev-parse --git-dir`;
chomp $GIT_DIR;
kill_svn_branch(@ARGV);
sub kill_svn_branch {
my $io;
my @refs;
for my $branch (@_) {
$branch =~ s{^remotes/}{};
system 'git', 'branch', '-r', '-D', $branch;
rmtree("$GIT_DIR/svn/refs/remotes/$branch");
open $io, '<', '.git/info/refs';
@refs = <$io>;
close $io;
@refs = grep { !m{\srefs/remotes/$branch$} } @refs;
open $io, '>', $GIT_DIR . '/info/refs';
print {$io} @refs;
close $io;
open $io, '<', $GIT_DIR . '/packed-refs';
@refs = <$io>;
close $io;
@refs = grep { !m{\srefs/remotes/$branch$} } @refs;
open $io, '>', $GIT_DIR . '/packed-refs';
print {$io} @refs;
close $io;
}
}