lib/svn2git/migration.rb in svn2git-2.3.2 vs lib/svn2git/migration.rb in svn2git-2.4.0

- old
+ new

@@ -45,15 +45,16 @@ options[:verbose] = false options[:metadata] = false options[:nominimizeurl] = false options[:rootistrunk] = false options[:trunk] = 'trunk' - options[:branches] = 'branches' - options[:tags] = 'tags' + options[:branches] = [] + options[:tags] = [] options[:exclude] = [] options[:revision] = nil options[:username] = nil + options[:password] = nil options[:rebasebranch] = false if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE)) options[:authors] = DEFAULT_AUTHORS_FILE end @@ -72,20 +73,24 @@ opts.on('--username NAME', 'Username for transports that needs it (http(s), svn)') do |username| options[:username] = username end + opts.on('--password PASSWORD', 'Password for transports that need it (http(s), svn)') do |password| + options[:password] = password + end + opts.on('--trunk TRUNK_PATH', 'Subpath to trunk from repository URL (default: trunk)') do |trunk| options[:trunk] = trunk end - opts.on('--branches BRANCHES_PATH', 'Subpath to branches from repository URL (default: branches)') do |branches| - options[:branches] = branches + opts.on('--branches BRANCHES_PATH', 'Subpath to branches from repository URL (default: branches); can be used multiple times') do |branches| + options[:branches] << branches end - opts.on('--tags TAGS_PATH', 'Subpath to tags from repository URL (default: tags)') do |tags| - options[:tags] = tags + opts.on('--tags TAGS_PATH', 'Subpath to tags from repository URL (default: tags); can be used multiple times') do |tags| + options[:tags] << tags 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 @@ -170,34 +175,51 @@ rootistrunk = @options[:rootistrunk] authors = @options[:authors] exclude = @options[:exclude] revision = @options[:revision] username = @options[:username] + password = @options[:password] 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 += "--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}" + cmd += "--trunk='#{@url}'" run_command(cmd, true, true) 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 += "--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 += "--trunk='#{trunk}' " unless trunk.nil? + unless tags.nil? + # Fill default tags here so that they can be filtered later + tags = ['tags'] if tags.empty? + # Process default or user-supplied tags + tags.each do |tag| + cmd += "--tags='#{tag}' " + end + end + unless branches.nil? + # Fill default branches here so that they can be filtered later + branches = ['branches'] if branches.empty? + # Process default or user-supplied branches + branches.each do |branch| + cmd += "--branches='#{branch}' " + end + end cmd += @url run_command(cmd, true, true) end @@ -214,14 +236,14 @@ # 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? + tags.each{|tag| regex << "#{tag}[/][^/]+[/]"} unless tags.nil? or tags.empty? + branches.each{|branch| regex << "#{branch}[/][^/]+[/]"} unless branches.nil? or branches.empty? end regex = '^(?:' + regex.join('|') + ')(?:' + exclude.join('|') + ')' - cmd += "'--ignore-paths=#{regex}'" + cmd += "--ignore-paths='#{regex}' " end run_command(cmd, true, true) get_branches end