Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ Options Reference
--trunk TRUNK_PATH Subpath to trunk from repository URL (default: trunk)
--branches BRANCHES_PATH Subpath to branches from repository URL (default: branches)
--tags TAGS_PATH Subpath to tags from repository URL (default: tags)
--tagparents Add tags without changes to its parent commit
--rootistrunk Use this if the root level of the repo is equivalent to the trunk and there are no tags or branches
--notrunk Do not import anything from trunk
--nobranches Do not try to import any branches
Expand Down Expand Up @@ -253,4 +254,7 @@ FAQ
that very same tag in the original svn repo. This is only due to the fact
that the svn tags allow changesets in them, making them not just annotated
tags.

In case your tags do not contain any changes, you can use `--tagparents`
to add the annotated tags to its parent.

12 changes: 11 additions & 1 deletion lib/svn2git/migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def parse(args)
options[:trunk] = 'trunk'
options[:branches] = 'branches'
options[:tags] = 'tags'
options[:tagparents] = false
options[:exclude] = []
options[:revision] = nil
options[:username] = nil
Expand Down Expand Up @@ -91,6 +92,10 @@ def parse(args)
options[:tags] = tags
end

opts.on('--tagparents', 'Add tags without changes to its parent commit') do
options[:tagparents] = true
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
Expand Down Expand Up @@ -285,12 +290,17 @@ def fix_tags
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
diff = run_command("git diff --shortstat \"#{escape_quotes(tag)}~1\" \"#{escape_quotes(tag)}\"")
run_command("#{git_config_command} user.name \"#{escape_quotes(author)}\"")
run_command("#{git_config_command} user.email \"#{escape_quotes(email)}\"")

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)}\"")
if diff.empty? and @options[:tagparents]
run_command("git tag -a -m \"#{escape_quotes(subject)}\" \"#{escape_quotes(id)}\" \"#{escape_quotes(tag)}~1\"")
else
run_command("git tag -a -m \"#{escape_quotes(subject)}\" \"#{escape_quotes(id)}\" \"#{escape_quotes(tag)}\"")
end
ENV['GIT_COMMITTER_DATE'] = original_git_committer_date

run_command("git branch -d -r \"#{escape_quotes(tag)}\"")
Expand Down