Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --shared option #201

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 29 additions & 35 deletions lib/svn2git/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def parse(args)
options[:verbose] = false
options[:metadata] = false
options[:nominimizeurl] = false
options[:rootistrunk] = false
options[:trunk] = 'trunk'
options[:branches] = 'branches'
options[:tags] = 'tags'
Expand All @@ -54,6 +53,7 @@ def parse(args)
options[:username] = nil
options[:password] = nil
options[:rebasebranch] = false
options[:shared] = nil

if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE))
options[:authors] = DEFAULT_AUTHORS_FILE
Expand Down Expand Up @@ -92,7 +92,6 @@ def parse(args)
end

opts.on('--rootistrunk', 'Use this if the root level of the repo is equivalent to the trunk and there are no tags or branches') do
options[:rootistrunk] = true
options[:trunk] = nil
options[:branches] = nil
options[:tags] = nil
Expand Down Expand Up @@ -138,6 +137,16 @@ def parse(args)
options[:rebasebranch] = rebasebranch
end

opts.on('--shared=[SHARED]', 'Set --shared option for git init') do |shared|
if shared
options[:shared] = "=#{shared}"
else
# git svn init seems to require an option, otherwise we'd leave
# this blank
options[:shared] = '=group'
end
end

opts.separator ""

# No argument, shows at tail. This will print an options summary.
Expand Down Expand Up @@ -172,43 +181,30 @@ def clone!
tags = @options[:tags]
metadata = @options[:metadata]
nominimizeurl = @options[:nominimizeurl]
rootistrunk = @options[:rootistrunk]
authors = @options[:authors]
exclude = @options[:exclude]
revision = @options[:revision]
username = @options[:username]
password = @options[:password]
shared = @options[:shared]

if rootistrunk
# Non-standard repository layout. The repository root is effectively 'trunk.'
cmd = "git svn init --prefix=svn/ "
cmd += "--username=#{username} " unless username.nil?
cmd += "--password=#{password} " unless password.nil?
cmd += "--no-metadata " unless metadata
if nominimizeurl
cmd += "--no-minimize-url "
end
cmd += "--trunk=#{@url}"
run_command(cmd, true, true)
cmd = "git svn init --prefix=svn/ "

else
cmd = "git svn init --prefix=svn/ "

# Add each component to the command that was passed as an argument.
cmd += "--username=#{username} " unless username.nil?
cmd += "--password=#{password} " unless password.nil?
cmd += "--no-metadata " unless metadata
if nominimizeurl
cmd += "--no-minimize-url "
end
cmd += "--trunk=#{trunk} " unless trunk.nil?
cmd += "--tags=#{tags} " unless tags.nil?
cmd += "--branches=#{branches} " unless branches.nil?
# Add each component to the command that was passed as an argument.
cmd += "--username=#{username} " unless username.nil?
cmd += "--password=#{password} " unless password.nil?
cmd += "--no-metadata " unless metadata
if nominimizeurl
cmd += "--no-minimize-url "
end
cmd += "--trunk=#{trunk} " unless trunk.nil?
cmd += "--tags=#{tags} " unless tags.nil?
cmd += "--branches=#{branches} " unless branches.nil?
cmd += "--shared#{shared} " unless shared.nil?

cmd += @url
cmd += @url

run_command(cmd, true, true)
end
run_command(cmd, true, true)

run_command("#{git_config_command} svn.authorsfile #{authors}") unless authors.nil?

Expand All @@ -222,11 +218,9 @@ def clone!
# Add exclude paths to the command line; some versions of git support
# this for fetch only, later also for init.
regex = []
unless rootistrunk
regex << "#{trunk}[/]" unless trunk.nil?
regex << "#{tags}[/][^/]+[/]" unless tags.nil?
regex << "#{branches}[/][^/]+[/]" unless branches.nil?
end
regex << "#{trunk}[/][^/]+[/]" unless trunk.nil? || trunk == '/'
regex << "#{tags}[/][^/]+[/]" unless tags.nil?
regex << "#{branches}[/][^/]+[/]" unless branches.nil?
regex = '^(?:' + regex.join('|') + ')(?:' + exclude.join('|') + ')'
cmd += "'--ignore-paths=#{regex}'"
end
Expand Down