Skip to content

Commit

Permalink
Fixed an issue with initial conversion if the repo had tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvdrum committed Feb 25, 2012
1 parent c7a601c commit 81ee6e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
3 changes: 3 additions & 0 deletions 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

Expand Down
25 changes: 14 additions & 11 deletions lib/svn2git/migration.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 = ''
Expand All @@ -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
Expand Down

0 comments on commit 81ee6e5

Please sign in to comment.