diff --git a/ChangeLog.markdown b/ChangeLog.markdown index b513b14..cab5fbc 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,6 +1,9 @@ # 2.2.1 + This is a critical bugfix release if your repository has tags. Thanks to David Zülke (dzuelke) for the patches making up this release. + * Added the ability to specify an end revision for migration (thanks dzuelke). + * Fixed an issue with initial conversion if the repo had tags (thanks dzuelke). # 2.2.0 - 2012-01-25 diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 9850fa3..f187d7b 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -215,8 +215,8 @@ def get_branches def fix_tags current = {} - current['user.name'] = run_command("git config --local --get user.name") - current['user.email'] = run_command("git config --local --get user.email") + current['user.name'] = run_command("git config --local --get user.name", false) + current['user.email'] = run_command("git config --local --get user.email", false) @tags.each do |tag| tag = tag.strip @@ -232,13 +232,16 @@ def fix_tags end ensure - 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[-1] == "\n" - run_command("git config --local #{name} '#{value.chomp("\n")}'") - else - run_command("git config --local --unset #{name}") + # 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}'") + else + run_command("git config --local --unset #{name}") + end end end end @@ -282,7 +285,7 @@ def optimize_repos run_command("git gc") end - def run_command(cmd) + def run_command(cmd, exit_on_error=true) log "Running command: #{cmd}" ret = '' @@ -295,7 +298,7 @@ def run_command(cmd) end end - unless $?.exitstatus == 0 + if exit_on_error && ($?.exitstatus != 0) $stderr.puts "command failed:\n#{cmd}" exit -1 end