Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc5ae1d

Browse files
author
Julian Taylor
committed
Merge remote branch 'kpruden/master'
2 parents 6f5658d + 170ad88 commit dc5ae1d

1 file changed

Lines changed: 25 additions & 3 deletions

File tree

lib/svn2git/migration.rb

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def initialize(args)
2222

2323
def run!
2424
if @options[:rebase]
25+
do_fetch if @options[:fetch]
2526
get_branches
2627
else
2728
clone!
@@ -42,6 +43,8 @@ def parse(args)
4243
options[:branches] = 'branches'
4344
options[:tags] = 'tags'
4445
options[:exclude] = []
46+
options[:revision] = nil
47+
options[:fetch] = nil
4548

4649
if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE))
4750
options[:authors] = DEFAULT_AUTHORS_FILE
@@ -105,6 +108,14 @@ def parse(args)
105108
options[:verbose] = true
106109
end
107110

111+
opts.on('--revision REV', 'Start fetch from specified revision') do |revision|
112+
options[:revision] = revision
113+
end
114+
115+
opts.on('--fetch', 'Before rebasing, do a git svn --fetch to pull in new branches (only valid when --rebase is specified)') do
116+
options[:fetch] = true
117+
end
118+
108119
opts.separator ""
109120

110121
# No argument, shows at tail. This will print an options summary.
@@ -129,6 +140,7 @@ def clone!
129140
rootistrunk = @options[:rootistrunk]
130141
authors = @options[:authors]
131142
exclude = @options[:exclude]
143+
revision = @options[:revision]
132144

133145
if rootistrunk
134146
# Non-standard repository layout. The repository root is effectively 'trunk.'
@@ -154,6 +166,7 @@ def clone!
154166
run_command("git config svn.authorsfile #{authors}") unless authors.nil?
155167

156168
cmd = "git svn fetch"
169+
cmd += " --revision=#{revision}" unless revision.nil?
157170
unless exclude.empty?
158171
# Add exclude paths to the command line; some versions of git support
159172
# this for fetch only, later also for init.
@@ -171,11 +184,20 @@ def clone!
171184
get_branches
172185
end
173186

187+
def do_fetch
188+
run_command("git svn fetch")
189+
end
190+
174191
def get_branches
175-
# Get the list of local and remote branches, taking care to ignore console color codes and ignoring the
176-
# '*' character used to indicate the currently selected branch.
192+
# Get the list of local and remote svn branches, taking care to ignore console color codes and ignoring
193+
# the '*' character used to indicate the currently selected branch.
194+
@remote_repos = run_command("git remote").split(/\n/).collect{ |b| b.strip }
177195
@local = run_command("git branch -l --no-color").split(/\n/).collect{ |b| b.gsub(/\*/,'').strip }
178-
@remote = run_command("git branch -r --no-color").split(/\n/).collect{ |b| b.gsub(/\*/,'').strip }
196+
@remote = run_command("git branch -r --no-color").split(/\n/).collect do |b|
197+
b.gsub(/\*/,'').strip
198+
end.find_all do
199+
|b| (@remote_repos.index{ |r| (b =~ /^#{r}\//) == 0 }) == nil
200+
end
179201

180202
# Tags are remote branches that start with "tags/".
181203
@tags = @remote.find_all { |b| b.strip =~ %r{^tags\/} }

0 commit comments

Comments
 (0)