lib/svn2git/migration.rb in svn2git-2.2.1 vs lib/svn2git/migration.rb in svn2git-2.2.2

- old
+ new

@@ -14,22 +14,22 @@ show_help_message('Too many arguments') if args.size > 0 verify_working_tree_is_clean else show_help_message('Missing SVN_URL parameter') if args.empty? show_help_message('Too many arguments') if args.size > 1 - @url = args.first + @url = args.first.gsub(' ', "\\ ") end end def run! if @options[:rebase] get_branches else clone! end - fix_tags fix_branches + fix_tags fix_trunk optimize_repos end def parse(args) @@ -219,27 +219,35 @@ current['user.email'] = run_command("git config --local --get user.email", false) @tags.each do |tag| tag = tag.strip id = tag.gsub(%r{^svn\/tags\/}, '').strip - subject = run_command("git log -1 --pretty=format:'%s' '#{escape_quotes(tag)}'") - date = run_command("git log -1 --pretty=format:'%ci' '#{escape_quotes(tag)}'") - author = run_command("git log -1 --pretty=format:'%an' '#{escape_quotes(tag)}'") - email = run_command("git log -1 --pretty=format:'%ae' '#{escape_quotes(tag)}'") - run_command("git config --local user.name '#{escape_quotes(author)}'") - run_command("git config --local user.email '#{escape_quotes(email)}'") - run_command("GIT_COMMITTER_DATE='#{escape_quotes(date)}' git tag -a -m '#{escape_quotes(subject)}' '#{escape_quotes(id)}' '#{escape_quotes(tag)}'") - run_command("git branch -d -r '#{escape_quotes(tag)}'") + subject = run_command("git log -1 --pretty=format:'%s' \"#{escape_quotes(tag)}\"").chomp("'").reverse.chomp("'").reverse + date = run_command("git log -1 --pretty=format:'%ci' \"#{escape_quotes(tag)}\"").chomp("'").reverse.chomp("'").reverse + author = run_command("git log -1 --pretty=format:'%an' \"#{escape_quotes(tag)}\"").chomp("'").reverse.chomp("'").reverse + email = run_command("git log -1 --pretty=format:'%ae' \"#{escape_quotes(tag)}\"").chomp("'").reverse.chomp("'").reverse + run_command("git config --local user.name \"#{escape_quotes(author)}\"") + run_command("git config --local user.email \"#{escape_quotes(email)}\"") + + begin + original_git_committer_date = ENV['GIT_COMMITTER_DATE'] + ENV['GIT_COMMITTER_DATE'] = escape_quotes(date) + run_command("git tag -a -m \"#{escape_quotes(subject)}\" \"#{escape_quotes(id)}\" \"#{escape_quotes(tag)}\"") + ensure + ENV['GIT_COMMITTER_DATE'] = original_git_committer_date + end + + run_command("git branch -d -r \"#{escape_quotes(tag)}\"") end ensure # We only change the git config values if there are @tags available. So it stands to reason we should revert them only in that case. unless @tags.empty? current.each_pair do |name, value| # If a line was read, then there was a config value so restore it. # Otherwise unset the value because originally there was none. if value.strip != '' - run_command("git config --local #{name} '#{value.strip}'") + run_command("git config --local #{name} \"#{value.strip}\"") else run_command("git config --local --unset #{name}") end end end