Permalink
Browse files

Fixed an issue with initial conversion if the repo had tags.

  • Loading branch information...
1 parent c7a601c commit 81ee6e5d1586b6954157da4a2ac23c71290dccab @nirvdrum committed Feb 25, 2012
Showing with 17 additions and 11 deletions.
  1. +3 −0 ChangeLog.markdown
  2. +14 −11 lib/svn2git/migration.rb
View
@@ -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
View
@@ -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

0 comments on commit 81ee6e5

Please sign in to comment.