From a610cddce61b3de0198079fab854294879ccbb64 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 1 Nov 2008 23:13:48 -0400 Subject: [PATCH 001/204] Fixed a problem with importing an SVN project that did not have any remote branches or tags. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 795a43b..f4d38b6 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -62,8 +62,8 @@ def fix_branches def fix_trunk trunk = @remote.find { |b| b.strip == @options[:trunk] } if trunk - `git branch -D master` `git checkout trunk` + `git branch -D master` `git checkout -f -b master` end end From 2d5303300dc0cf2097e19350e723c7919c7e0dc5 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 1 Nov 2008 23:35:06 -0400 Subject: [PATCH 002/204] Changed the way commands are run from using backticks to IO.popen. This allows us to grab STDOUT in realtime in order to show what's going on. --- lib/svn2git/migration.rb | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index f4d38b6..ebc8c78 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -28,9 +28,9 @@ def clone! trunk = @options[:trunk] branches = @options[:branches] tags = @options[:tags] - `git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} --tags=#{tags} #{@url}` - `git config svn.authorsfile #{@authors}` if @authors - `git svn fetch` + run_command("git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} --tags=#{tags} #{@url}") + run_command("git config svn.authorsfile #{@authors}") if @authors + run_command("git svn fetch") get_branches end @@ -44,8 +44,8 @@ def get_branches def fix_tags @tags.each do |tag| id = tag.strip.gsub(%r{^#{@options[:tags]}\/}, '') - `git checkout #{tag}` - `git tag -a -m "Tagging release #{id}" #{id}` + run_command("git checkout #{tag}") + run_command("git tag -a -m 'Tagging release #{id}' #{id}") end end @@ -54,17 +54,25 @@ def fix_branches svn_branches.each do |branch| branch = branch.strip next if branch == @options[:trunk] - `git checkout #{branch}` - `git checkout -b #{branch}` + run_command("git checkout #{branch}") + run_command("git checkout -b #{branch}") end end def fix_trunk trunk = @remote.find { |b| b.strip == @options[:trunk] } if trunk - `git checkout trunk` - `git branch -D master` - `git checkout -f -b master` + run_command("git checkout trunk") + run_command("git branch -D master") + run_command("git checkout -f -b master") + end + end + + def run_command(cmd) + IO.popen(cmd) do |stdout| + stdout.each do |line| + puts line if @options[:verbose] + end end end From b751a72b4d9b2ea54999d12bb160bb3db1c71ed4 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 2 Nov 2008 10:04:05 -0500 Subject: [PATCH 003/204] Added the ability to load a default authors file out of ~/.svn2git/authors. --- README | 3 +++ lib/svn2git/migration.rb | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/README b/README index 4278cd9..46874c0 100644 --- a/README +++ b/README @@ -87,3 +87,6 @@ Then pass an +authors+ option to +svn2git+ pointing to your file: svn2git http://repos.com/myproject authors=~/authors.txt +Alternatively, you can place the authors file into ~/.svn2git/authors and svn2git will load +it out of there. This allows you to build up one authors file for all your projects and +have it loaded for each repository that you migrate. \ No newline at end of file diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index ebc8c78..428a765 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -1,4 +1,6 @@ module Svn2Git + DEFAULT_AUTHORS_FILE = "~/.svn2git/authors" + class Migration attr_reader :dir @@ -13,6 +15,9 @@ def initialize(url, options = {}) @options[:tags] ||= 'tags' @authors = options[:authors] + if @authors.nil? && File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE)) + @authors = DEFAULT_AUTHORS_FILE + end end def run! From 8196340fd6815ea7b9e443019bbc1d4c8f0e88a8 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 2 Nov 2008 17:06:11 -0500 Subject: [PATCH 004/204] git svn actually aliases a remote branch named 'trunk' to whatever is passed as the --trunk parameter, so we should always use 'trunk' as the branch name to look for. --- lib/svn2git/migration.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 428a765..0f25423 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -58,14 +58,14 @@ def fix_branches svn_branches = @remote.find_all { |b| not @tags.include?(b) } svn_branches.each do |branch| branch = branch.strip - next if branch == @options[:trunk] + next if branch == 'trunk' run_command("git checkout #{branch}") run_command("git checkout -b #{branch}") end end def fix_trunk - trunk = @remote.find { |b| b.strip == @options[:trunk] } + trunk = @remote.find { |b| b.strip == 'trunk' } if trunk run_command("git checkout trunk") run_command("git branch -D master") From 6c3d22a80260844a65d51b6d18ad9b00f12b9f3d Mon Sep 17 00:00:00 2001 From: Andrew De Ponte Date: Thu, 25 Dec 2008 08:40:51 +0800 Subject: [PATCH 005/204] - Modified to create tags predated w/ orig logs. - Modified to remove tag branches after tagging. - Modified to change checkout trunk before deleting master and delete trunk branch after master is switched over. Signed-off-by: Kevin Menard --- lib/svn2git/migration.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 0f25423..95bc5ab 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -49,8 +49,11 @@ def get_branches def fix_tags @tags.each do |tag| id = tag.strip.gsub(%r{^#{@options[:tags]}\/}, '') - run_command("git checkout #{tag}") - run_command("git tag -a -m 'Tagging release #{id}' #{id}") + subject = `git log -1 --pretty=format:"%s" #{tag.strip()}` + date = `git log -1 --pretty=format:"%ci" #{tag.strip()}` + `export GIT_COMMITER_DATE="#{date}"` + run_command('git tag -a -m "#{subject}" "#{id.strip()}" "#{tag.strip()}^"') + run_command('git branch -d -r #{tag.strip()}') end end @@ -70,6 +73,7 @@ def fix_trunk run_command("git checkout trunk") run_command("git branch -D master") run_command("git checkout -f -b master") + run_command("git branch -d -r trunk") end end From 1faa905190f737da064f3dea54897dbb7ee6dcd1 Mon Sep 17 00:00:00 2001 From: Andrew De Ponte Date: Sat, 3 Jan 2009 06:28:20 +0800 Subject: [PATCH 006/204] - Fixed a problem introduced in rev c34aed328933f34fc1226616fc1a3c08ec2288a5 where #{} were not getting evaluated in the single quotes. - Added repo cleaning and optimization after conversion completes. - Changes usage (documented in README) and added handling for other svn repo layouts. Note: Usage no longer defaults to standard repo layouts. Signed-off-by: Kevin Menard --- README | 74 +++++++++++++++++++++++++++++----------- lib/svn2git/migration.rb | 31 +++++++++++++---- 2 files changed, 79 insertions(+), 26 deletions(-) diff --git a/README b/README index 46874c0..aa76d04 100644 --- a/README +++ b/README @@ -1,10 +1,11 @@ == svn2git -+svn2git+ is a tiny utility for migrating projects from Subversion to Git while keeping -the trunk, branches and tags where they should be. It uses git-svn to clone an svn repository -and does some clean-up to make sure branches and tags are imported in a meaningful way, and -that the code checked into master ends up being what's currently in your svn trunk rather -than whichever svn branch your last commit was in. ++svn2git+ is a tiny utility for migrating projects from Subversion to Git +while keeping the trunk, branches and tags where they should be. It uses +git-svn to clone an svn repository and does some clean-up to make sure +branches and tags are imported in a meaningful way, and that the code checked +into master ends up being what's currently in your svn trunk rather than +whichever svn branch your last commit was in. === Examples @@ -22,9 +23,10 @@ Say I have this code in svn: 1.1.0 2.0.0 -git-svn will go through the commit history to build a new git repo. It will import all branches -and tags as remote svn branches, whereas what you really want is git-native local branches and -git tag objects. So after importing this project I'll get: +git-svn will go through the commit history to build a new git repo. It will +import all branches and tags as remote svn branches, whereas what you really +want is git-native local branches and git tag objects. So after importing this +project I'll get: $ git branch * master @@ -54,7 +56,8 @@ After svn2git is done with your project, you'll get this instead: 1.1.0 2.0.0 -Finally, it makes sure the HEAD of master is the same as the current trunk of the svn repo. +Finally, it makes sure the HEAD of master is the same as the current trunk of +the svn repo. === Installation @@ -65,20 +68,50 @@ Make sure you have git installed, then install the gem: === Usage -To create a git repo from an existing svn repo: +There are a number of ways in which you can create a git repo from an existing +svn repo. The differentiating factor is the svn repo layout. Below is an +enumerated listing of the varying supported layouts and the proper way to +create a git repo from a svn repo in the specified layout. - $ svn2git http://svn.yoursite.com/path/to/repo +1. The svn repo is in the standard layout of (trunk, branches, tags) at the +root level of the repo. -This will create a git repository in the current directory with the git version of the svn -repository. If you're not using the standard trunk/branches/tags layout, you can pass arguments -to tell git-svn what to look for: + $ svn2git http://svn.yoursite.com/path/to/repo trunk=trunk branches=branches tags=tags - $ svn2git http://svn.yoursite.com/path/to/repo trunk=the_trunk tags=taggings +2. The svn repo is NOT in standard layout and has only a trunk and tags at the +root level of the repo. + + $ svn2git http://svn.yoursite.com/path/to/repo trunk=trunk tags=tags + +3. The svn repo is NOT in standard layout and has only a trunk and branches at +the root level of the repo. + + $ svn2git http://svn.yoursite.com/path/to/repo trunk=trunk branches=branches + +4. The svn repo is NOT in standard layout and has only a trunk at the root +level of the repo. + + $ svn2git http://svn.yoursite.com/path/to/repo trunk=trunk + +5. The svn repo is NOT in standard layout and has no trunk, branches, or tags +at the root level of the repo. Instead the root level of the repo is +equivalent to the trunk and there are no tags or branches. + + $ svn2git http://svn.yoursite.com/path/to/repo rootistrunk=true + +The above will create a git repository in the current directory with the git +version of the svn repository. Hence, you need to make a directory that you +want your new git repo to exist in, change into it and then run one of the +above commands. Note that in the above cases the trunk, branches, tags options +are simply folder names relative to the provided repo path. For example if you +specified trunk=foo branches=bar and tags=foobar it would be referencing +http://svn.yoursite.com/path/to/repo/foo as your trunk, and so on. However, in +case 5 it references the root of the repo as trunk. === Authors -To convert all your svn authors to git format, create a file somewhere on your system with -the list of conversions to make, one per line, for example: +To convert all your svn authors to git format, create a file somewhere on your +system with the list of conversions to make, one per line, for example: jcoglan = James Coglan stnick = Santa Claus @@ -87,6 +120,7 @@ Then pass an +authors+ option to +svn2git+ pointing to your file: svn2git http://repos.com/myproject authors=~/authors.txt -Alternatively, you can place the authors file into ~/.svn2git/authors and svn2git will load -it out of there. This allows you to build up one authors file for all your projects and -have it loaded for each repository that you migrate. \ No newline at end of file +Alternatively, you can place the authors file into ~/.svn2git/authors and +svn2git will load it out of there. This allows you to build up one authors +file for all your projects and have it loaded for each repository that you +migrate. \ No newline at end of file diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 95bc5ab..1c9a272 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -10,9 +10,9 @@ def initialize(url, options = {}) @dir = @url.scan(/[^\/]+/).last @options = options - @options[:trunk] ||= 'trunk' - @options[:branches] ||= 'branches' - @options[:tags] ||= 'tags' + #@options[:trunk] ||= 'trunk' + #@options[:branches] ||= 'branches' + #@options[:tags] ||= 'tags' @authors = options[:authors] if @authors.nil? && File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE)) @@ -25,6 +25,7 @@ def run! fix_tags fix_branches fix_trunk + optimize_repos end private @@ -33,9 +34,21 @@ def clone! trunk = @options[:trunk] branches = @options[:branches] tags = @options[:tags] - run_command("git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} --tags=#{tags} #{@url}") + rootistrunk = @options[:rootistrunk] + if (!rootistrunk.nil?()) + run_command("git svn init --no-metadata --trunk=#{@url}") + elsif (branches.nil?() and tags.nil?() and !trunk.nil?()) + run_command("git svn init --no-metadata --trunk=#{trunk} #{@url}") + elsif (branches.nil?() and !tags.nil?() and !trunk.nil?()) + run_command("git svn init --no-metadata --trunk=#{trunk} --tags=#{tags} #{@url}") + elsif (!branches.nil?() and tags.nil?() and !trunk.nil?()) + run_command("git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} #{@url}") + else + run_command("git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} --tags=#{tags} #{@url}") + end run_command("git config svn.authorsfile #{@authors}") if @authors run_command("git svn fetch") + @options[:tags] ||= 'tags' get_branches end @@ -52,8 +65,10 @@ def fix_tags subject = `git log -1 --pretty=format:"%s" #{tag.strip()}` date = `git log -1 --pretty=format:"%ci" #{tag.strip()}` `export GIT_COMMITER_DATE="#{date}"` - run_command('git tag -a -m "#{subject}" "#{id.strip()}" "#{tag.strip()}^"') - run_command('git branch -d -r #{tag.strip()}') + cmd = 'git tag -a -m "' + subject + '" "' + id.strip() + '" "' + tag.strip() + '^"' + run_command(cmd) + cmd = 'git branch -d -r ' + tag.strip() + run_command(cmd) end end @@ -77,6 +92,10 @@ def fix_trunk end end + def optimize_repos + run_command("git gc") + end + def run_command(cmd) IO.popen(cmd) do |stdout| stdout.each do |line| From dc8faa36b9a52b08f86e1ca9f0e9f49b902eeedc Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 2 Jan 2009 18:03:48 -0500 Subject: [PATCH 007/204] Code clean-ups. --- lib/svn2git/migration.rb | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 1c9a272..ce3abab 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -35,19 +35,22 @@ def clone! branches = @options[:branches] tags = @options[:tags] rootistrunk = @options[:rootistrunk] - if (!rootistrunk.nil?()) + + if (!rootistrunk.nil?) run_command("git svn init --no-metadata --trunk=#{@url}") - elsif (branches.nil?() and tags.nil?() and !trunk.nil?()) + elsif (branches.nil? and tags.nil? and !trunk.nil?) run_command("git svn init --no-metadata --trunk=#{trunk} #{@url}") - elsif (branches.nil?() and !tags.nil?() and !trunk.nil?()) + elsif (branches.nil? and !tags.nil? and !trunk.nil?) run_command("git svn init --no-metadata --trunk=#{trunk} --tags=#{tags} #{@url}") - elsif (!branches.nil?() and tags.nil?() and !trunk.nil?()) + elsif (!branches.nil? and tags.nil? and !trunk.nil?) run_command("git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} #{@url}") else run_command("git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} --tags=#{tags} #{@url}") end + run_command("git config svn.authorsfile #{@authors}") if @authors run_command("git svn fetch") + @options[:tags] ||= 'tags' get_branches end @@ -65,10 +68,8 @@ def fix_tags subject = `git log -1 --pretty=format:"%s" #{tag.strip()}` date = `git log -1 --pretty=format:"%ci" #{tag.strip()}` `export GIT_COMMITER_DATE="#{date}"` - cmd = 'git tag -a -m "' + subject + '" "' + id.strip() + '" "' + tag.strip() + '^"' - run_command(cmd) - cmd = 'git branch -d -r ' + tag.strip() - run_command(cmd) + run_command("git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}^'") + run_command("git branch -d -r #{tag.strip()}") end end From ab729bec207e60bf431115fef2ea855ca676f79a Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 2 Jan 2009 18:05:47 -0500 Subject: [PATCH 008/204] Whitespace additions. --- lib/svn2git/migration.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index ce3abab..88f507e 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -38,12 +38,16 @@ def clone! if (!rootistrunk.nil?) run_command("git svn init --no-metadata --trunk=#{@url}") + elsif (branches.nil? and tags.nil? and !trunk.nil?) run_command("git svn init --no-metadata --trunk=#{trunk} #{@url}") + elsif (branches.nil? and !tags.nil? and !trunk.nil?) run_command("git svn init --no-metadata --trunk=#{trunk} --tags=#{tags} #{@url}") + elsif (!branches.nil? and tags.nil? and !trunk.nil?) run_command("git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} #{@url}") + else run_command("git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} --tags=#{tags} #{@url}") end From 6c0d19f9c9e44c7ef3aa5b415dd39f14c3651f17 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 2 Jan 2009 18:13:23 -0500 Subject: [PATCH 009/204] Simplified a bunch of branching logic. --- lib/svn2git/migration.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 88f507e..7affe0b 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -37,25 +37,25 @@ def clone! rootistrunk = @options[:rootistrunk] if (!rootistrunk.nil?) + # Non-standard repository layout. The repository root is effectively 'trunk.' run_command("git svn init --no-metadata --trunk=#{@url}") - - elsif (branches.nil? and tags.nil? and !trunk.nil?) - run_command("git svn init --no-metadata --trunk=#{trunk} #{@url}") - - elsif (branches.nil? and !tags.nil? and !trunk.nil?) - run_command("git svn init --no-metadata --trunk=#{trunk} --tags=#{tags} #{@url}") - - elsif (!branches.nil? and tags.nil? and !trunk.nil?) - run_command("git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} #{@url}") else - run_command("git svn init --no-metadata --trunk=#{trunk} --branches=#{branches} --tags=#{tags} #{@url}") + cmd = "git svn init --no-metadata " + + # Add each component to the command that was passed as an argument. + cmd += "--trunk=#{trunk} " unless trunk.nil? + cmd += "--tags=#{tags} " unless tags.nil? + cmd += "--branches=#{branches} " unless branches.nil? + + cmd += @url + + run_command(cmd) end run_command("git config svn.authorsfile #{@authors}") if @authors run_command("git svn fetch") - @options[:tags] ||= 'tags' get_branches end From 7f34e08e9f00fedbf26b1af0ccc0b346c8b7f293 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 2 Jan 2009 18:15:13 -0500 Subject: [PATCH 010/204] Bumping version number of gem. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index bae6ea9..bb95074 100644 --- a/Rakefile +++ b/Rakefile @@ -3,7 +3,7 @@ require 'rake/gempackagetask' spec = Gem::Specification.new do |spec| spec.name = "svn2git" - spec.version = "1.0.0" + spec.version = "1.1.0" spec.platform = Gem::Platform::RUBY spec.summary = "A tool for migrating svn projects to git" From b3b7de8df01057e0f58924e34863bc972fe4f521 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 2 Jan 2009 18:33:55 -0500 Subject: [PATCH 011/204] No need to ever commit the pkg directory. --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5fff1d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +pkg From 89459019b866c138a2d2d066493d159d9c604abb Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 2 Jan 2009 18:34:42 -0500 Subject: [PATCH 012/204] Re-enabled the default branches, tags, and trunk options. We probably need a better way of disabling them. Also started extracting the logging. Probably best to use a standard logger. --- lib/svn2git/migration.rb | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 7affe0b..84d12c8 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -10,9 +10,9 @@ def initialize(url, options = {}) @dir = @url.scan(/[^\/]+/).last @options = options - #@options[:trunk] ||= 'trunk' - #@options[:branches] ||= 'branches' - #@options[:tags] ||= 'tags' + @options[:trunk] ||= 'trunk' + @options[:branches] ||= 'branches' + @options[:tags] ||= 'tags' @authors = options[:authors] if @authors.nil? && File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE)) @@ -102,13 +102,21 @@ def optimize_repos end def run_command(cmd) + log "Running command: #{cmd}" + IO.popen(cmd) do |stdout| stdout.each do |line| - puts line if @options[:verbose] + log line end end end - + + private + + def log(msg) + puts msg if @options[:verbose] + end + end end From b3b0cb8b18eaa4a05b9bcb2aeb4d9963bf5b51eb Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 2 Jan 2009 18:36:34 -0500 Subject: [PATCH 013/204] Simplified the logic for detecting remote branches. --- lib/svn2git/migration.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 84d12c8..9c2efa7 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -60,9 +60,7 @@ def clone! end def get_branches - @branches = `git branch -a`.split(/\n/) - @local = `git branch`.split(/\n/) - @remote = @branches.find_all { |b| not @local.include?(b) } + @remote = `git branch -r`.split(/\n/) @tags = @remote.find_all { |b| b.strip =~ %r{^#{@options[:tags]}\/} } end From fbb37c581a57c177f32f643d18c584297084235f Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 2 Jan 2009 18:42:22 -0500 Subject: [PATCH 014/204] Don't strip the last commit to the tag on the off-chance it contained more than just a cp. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 9c2efa7..06c2151 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -70,7 +70,7 @@ def fix_tags subject = `git log -1 --pretty=format:"%s" #{tag.strip()}` date = `git log -1 --pretty=format:"%ci" #{tag.strip()}` `export GIT_COMMITER_DATE="#{date}"` - run_command("git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}^'") + run_command("git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}'") run_command("git branch -d -r #{tag.strip()}") end end From 822f96fa4b31bc6ba2c9e8fb01028d2f3b5e010f Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 2 Jan 2009 18:44:25 -0500 Subject: [PATCH 015/204] No need to specify the tag revision if we're using the base one. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 06c2151..e48806a 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -70,7 +70,7 @@ def fix_tags subject = `git log -1 --pretty=format:"%s" #{tag.strip()}` date = `git log -1 --pretty=format:"%ci" #{tag.strip()}` `export GIT_COMMITER_DATE="#{date}"` - run_command("git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}'") + run_command("git tag -a -m '#{subject}' '#{id.strip()}'") run_command("git branch -d -r #{tag.strip()}") end end From d29d0986a1fb17b077177f000d8a9795c8f18261 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 3 Jan 2009 11:18:22 -0500 Subject: [PATCH 016/204] Undo my latest change. Turns out we do need to specify the tag head because we no longer check the tag out. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index e48806a..6f28de1 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -70,7 +70,7 @@ def fix_tags subject = `git log -1 --pretty=format:"%s" #{tag.strip()}` date = `git log -1 --pretty=format:"%ci" #{tag.strip()}` `export GIT_COMMITER_DATE="#{date}"` - run_command("git tag -a -m '#{subject}' '#{id.strip()}'") + run_command("git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}") run_command("git branch -d -r #{tag.strip()}") end end From 2091a01d4441cb61abe6e7d2636d99de327472c8 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 3 Jan 2009 11:41:32 -0500 Subject: [PATCH 017/204] Missed a trailing quote. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 6f28de1..06c2151 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -70,7 +70,7 @@ def fix_tags subject = `git log -1 --pretty=format:"%s" #{tag.strip()}` date = `git log -1 --pretty=format:"%ci" #{tag.strip()}` `export GIT_COMMITER_DATE="#{date}"` - run_command("git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}") + run_command("git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}'") run_command("git branch -d -r #{tag.strip()}") end end From 06082cb58edccc627b4c14881c5ccabb359539ff Mon Sep 17 00:00:00 2001 From: KUBO Atsuhiro Date: Thu, 12 Feb 2009 23:59:43 +0900 Subject: [PATCH 018/204] Fixed a defect so that the svn2git command didn't work as a gem package. --- bin/svn2git | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/svn2git b/bin/svn2git index 2d2055c..aff089c 100644 --- a/bin/svn2git +++ b/bin/svn2git @@ -20,6 +20,9 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +require 'rubygems' +gem 'svn2git' + require 'svn2git' url = ARGV.shift From e0a8db671e85accdcd5d762db196abf36926b3be Mon Sep 17 00:00:00 2001 From: KUBO Atsuhiro Date: Fri, 13 Feb 2009 08:59:04 +0900 Subject: [PATCH 019/204] - Fixed a defect so that no tags were found by git tag -l and all branches like tags/xxx were still found after migration using the tags option with a non-standard name like releases because git-svn already made branches named like tags/xxx even though any tag was specified. --- lib/svn2git/migration.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 06c2151..ca1deec 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -61,12 +61,12 @@ def clone! def get_branches @remote = `git branch -r`.split(/\n/) - @tags = @remote.find_all { |b| b.strip =~ %r{^#{@options[:tags]}\/} } + @tags = @remote.find_all { |b| b.strip =~ %r{^tags\/} } end def fix_tags @tags.each do |tag| - id = tag.strip.gsub(%r{^#{@options[:tags]}\/}, '') + id = tag.strip.gsub(%r{^tags\/}, '') subject = `git log -1 --pretty=format:"%s" #{tag.strip()}` date = `git log -1 --pretty=format:"%ci" #{tag.strip()}` `export GIT_COMMITER_DATE="#{date}"` From c7fc87dd908a4b7aaacc8ef151ca38983111b2b9 Mon Sep 17 00:00:00 2001 From: KUBO Atsuhiro Date: Thu, 12 Feb 2009 22:59:43 +0800 Subject: [PATCH 020/204] Fixed a defect so that the svn2git command didn't work as a gem package. Signed-off-by: Kevin Menard --- bin/svn2git | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/svn2git b/bin/svn2git index 2d2055c..aff089c 100644 --- a/bin/svn2git +++ b/bin/svn2git @@ -20,6 +20,9 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +require 'rubygems' +gem 'svn2git' + require 'svn2git' url = ARGV.shift From d3a8b5b581d8de7a728195c86ef30e05b74a6585 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:40:56 -0400 Subject: [PATCH 021/204] Version bump to 0.0.0 --- VERSION.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 VERSION.yml diff --git a/VERSION.yml b/VERSION.yml new file mode 100644 index 0000000..44cd0bc --- /dev/null +++ b/VERSION.yml @@ -0,0 +1,4 @@ +--- +:patch: 0 +:major: 0 +:minor: 0 From d0bd7ab34b0720559323c59065d5a7f5dad6574f Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:41:24 -0400 Subject: [PATCH 022/204] Version bump to 1.0.0 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 44cd0bc..7b326df 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- :patch: 0 -:major: 0 +:major: 1 :minor: 0 From ed238ee09ea6eb48e66420245b86790a451c492c Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:41:31 -0400 Subject: [PATCH 023/204] Version bump to 1.1.0 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 7b326df..6f08913 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- :patch: 0 :major: 1 -:minor: 0 +:minor: 1 From 8feed2be37f4d988f9c39201bd4b1a1ee119b023 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:41:35 -0400 Subject: [PATCH 024/204] Version bump to 1.1.1 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 6f08913..5e83768 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- -:patch: 0 +:patch: 1 :major: 1 :minor: 1 From 0f6bce2c8915a7c1a81a5c454a6a236dccc27f32 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:51:52 -0400 Subject: [PATCH 025/204] Fixed #19: Switch to jeweler for gem management --- Rakefile | 64 ++++++++++++++++++++++++++++++------------------- svn2git.gemspec | 39 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 25 deletions(-) create mode 100644 svn2git.gemspec diff --git a/Rakefile b/Rakefile index bb95074..2e5095c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,30 +1,44 @@ require 'rake' require 'rake/gempackagetask' -spec = Gem::Specification.new do |spec| - spec.name = "svn2git" - spec.version = "1.1.0" - spec.platform = Gem::Platform::RUBY - spec.summary = "A tool for migrating svn projects to git" +begin + require 'jeweler' + Jeweler::Tasks.new do |spec| + spec.name = "svn2git" + spec.summary = "A tool for migrating svn projects to git" + spec.authors = ["James Coglan", "Kevin Menard"] + spec.homepage = "https://www.negativetwenty.net/redmine/projects/svn2git" + spec.email = "nirvdrum@gmail.com" + end - spec.require_path = "lib" - spec.files = FileList["lib/**/*"].to_a - spec.autorequire = "lib/svn2git.rb" - spec.bindir = "bin" - spec.executables = ["svn2git"] - spec.default_executable = "svn2git" - - spec.author = "James Coglan" - spec.email = "james@jcoglan.com" - spec.homepage = "http://github.com/jcoglan/svn2git/" - - spec.test_files = FileList["test/**/*"].to_a - spec.has_rdoc = true - spec.extra_rdoc_files = ["README"] - spec.rdoc_options << "--main" << "README" << '--line-numbers' << '--inline-source' +rescue LoadError + puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" end - -Rake::GemPackageTask.new(spec) do |pkg| - pkg.need_tar = true -end - + +# +# spec = Gem::Specification.new do |spec| +# +# spec.version = "1.1.0" +# spec.platform = Gem::Platform::RUBY +# +# +# spec.require_path = "lib" +# spec.files = FileList["lib/**/*"].to_a +# spec.autorequire = "lib/svn2git.rb" +# spec.bindir = "bin" +# spec.executables = ["svn2git"] +# spec.default_executable = "svn2git" +# +# +# +# +# spec.test_files = FileList["test/**/*"].to_a +# spec.has_rdoc = true +# spec.extra_rdoc_files = ["README"] +# spec.rdoc_options << "--main" << "README" << '--line-numbers' << '--inline-source' +# end +# +# Rake::GemPackageTask.new(spec) do |pkg| +# pkg.need_tar = true +# end +# diff --git a/svn2git.gemspec b/svn2git.gemspec new file mode 100644 index 0000000..9c38c8c --- /dev/null +++ b/svn2git.gemspec @@ -0,0 +1,39 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{svn2git} + s.version = "1.1.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["James Coglan", "Kevin Menard"] + s.date = %q{2009-04-15} + s.default_executable = %q{svn2git} + s.email = %q{nirvdrum@gmail.com} + s.executables = ["svn2git"] + s.extra_rdoc_files = [ + "README" + ] + s.files = [ + "Rakefile", + "VERSION.yml", + "bin/svn2git", + "lib/svn2git.rb", + "lib/svn2git/migration.rb" + ] + s.has_rdoc = true + s.homepage = %q{https://www.negativetwenty.net/redmine/projects/svn2git} + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.1} + s.summary = %q{A tool for migrating svn projects to git} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end From c59bbd8921410f2d57e92e33b5dbda082bfc6834 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:53:22 -0400 Subject: [PATCH 026/204] Back the version down to match the last release. --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 5e83768..d4936b7 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- :patch: 1 :major: 1 -:minor: 1 +:minor: 0 From 83335e482a79fa0b67c9a22398412d9018487c6a Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:53:27 -0400 Subject: [PATCH 027/204] Regenerated gemspec for version 1.0.1 --- svn2git.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 9c38c8c..c4a03e9 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "1.1.1" + s.version = "1.0.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] From f92c136bf36fad9bec52ea07784dee17bcc49e0e Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:53:56 -0400 Subject: [PATCH 028/204] Version bump to 1.0.2 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index d4936b7..36a4926 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- -:patch: 1 +:patch: 2 :major: 1 :minor: 0 From 568ceda093ac1fa137f6fdf08064ba20f650f215 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:54:05 -0400 Subject: [PATCH 029/204] Version bump to 1.1.0 --- VERSION.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION.yml b/VERSION.yml index 36a4926..6f08913 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- -:patch: 2 +:patch: 0 :major: 1 -:minor: 0 +:minor: 1 From 9c586883bb47ba921fb3f2c3e2567cd9bffc5bdf Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:54:11 -0400 Subject: [PATCH 030/204] Version bump to 1.1.1 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 6f08913..5e83768 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- -:patch: 0 +:patch: 1 :major: 1 :minor: 1 From f9aa30082c4f2b99a204a2033b02b23f4d53f875 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 15 Apr 2009 20:54:23 -0400 Subject: [PATCH 031/204] Regenerated gemspec for version 1.1.1 --- svn2git.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index c4a03e9..9c38c8c 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "1.0.1" + s.version = "1.1.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] From 1ded6bb8685c06b72c2b419a6218ae43e0b6a2e8 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 17 Apr 2009 08:12:46 -0400 Subject: [PATCH 032/204] Fixed #3: Use optparse for command-line option handling. --- lib/svn2git/migration.rb | 133 ++++++++++++++++++++++++++++----------- 1 file changed, 96 insertions(+), 37 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 06c2151..2b34986 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -1,25 +1,20 @@ +require 'optparse' +require 'pp' + module Svn2Git DEFAULT_AUTHORS_FILE = "~/.svn2git/authors" - + class Migration - + attr_reader :dir - - def initialize(url, options = {}) - @url = url - @dir = @url.scan(/[^\/]+/).last - - @options = options - @options[:trunk] ||= 'trunk' - @options[:branches] ||= 'branches' - @options[:tags] ||= 'tags' - - @authors = options[:authors] - if @authors.nil? && File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE)) - @authors = DEFAULT_AUTHORS_FILE - end + + def initialize(args) + @options = parse(args) + show_help_message('Too many arguments') if args.size > 1 + + @url = args.first end - + def run! clone! fix_tags @@ -27,43 +22,103 @@ def run! fix_trunk optimize_repos end - + + def parse(args) + # Set up reasonable defaults for options. + options = {} + options[:verbose] = false + options[:rootistrunk] = false + options[:trunk] = 'trunk' + options[:branches] = 'branches' + options[:tags] = 'tags' + + if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE)) + options[:authors] = DEFAULT_AUTHORS_FILE + end + + + # Parse the command-line arguments. + @opts = OptionParser.new do |opts| + opts.banner = 'Usage: svn2git SVN_URL [options]' + + opts.separator '' + opts.separator 'Specific options:' + + opts.on('--trunk TRUNK_PATH', 'Subpath to trunk from repository URL (default: trunk)') do |trunk| + options[:trunk] = trunk + end + + opts.on('--branches BRANCHES_PATH', 'Subpath to branches from repository URL (default: branches)') do |branches| + options[:branches] = branches + end + + opts.on('--tags TAGS_PATH', 'Subpath to tags from repository URL (default: tags)') do |tags| + options[:tags] = tags + end + + opts.on('--authors AUTHORS_FILE', "Path to file containing svn-to-git authors mapping (default: #{DEFAULT_AUTHORS_FILE})") do |authors| + options[:authors] = authors + end + + opts.on('--rootistrunk', 'Use this if the root level of the repo isequivalent to the trunk and there are no tags or branches') do + options[:rootistrunk] = true + end + + opts.on('-v', '--verbose', 'Be verbose in logging -- useful for debugging issues') do + options[:verbose] = true + end + + opts.separator "" + + # No argument, shows at tail. This will print an options summary. + # Try it and see! + opts.on_tail('-h', '--help', 'Show this message') do + puts opts + exit + end + end + + @opts.parse! args + options + end + private - + def clone! trunk = @options[:trunk] branches = @options[:branches] tags = @options[:tags] rootistrunk = @options[:rootistrunk] - - if (!rootistrunk.nil?) + authors = @options[:authors] + + if rootistrunk # Non-standard repository layout. The repository root is effectively 'trunk.' run_command("git svn init --no-metadata --trunk=#{@url}") - + else cmd = "git svn init --no-metadata " - + # Add each component to the command that was passed as an argument. cmd += "--trunk=#{trunk} " unless trunk.nil? cmd += "--tags=#{tags} " unless tags.nil? cmd += "--branches=#{branches} " unless branches.nil? - + cmd += @url - + run_command(cmd) end - - run_command("git config svn.authorsfile #{@authors}") if @authors + + run_command("git config svn.authorsfile #{authors}") if authors run_command("git svn fetch") - + get_branches end - + def get_branches @remote = `git branch -r`.split(/\n/) @tags = @remote.find_all { |b| b.strip =~ %r{^#{@options[:tags]}\/} } end - + def fix_tags @tags.each do |tag| id = tag.strip.gsub(%r{^#{@options[:tags]}\/}, '') @@ -74,7 +129,7 @@ def fix_tags run_command("git branch -d -r #{tag.strip()}") end end - + def fix_branches svn_branches = @remote.find_all { |b| not @tags.include?(b) } svn_branches.each do |branch| @@ -84,7 +139,7 @@ def fix_branches run_command("git checkout -b #{branch}") end end - + def fix_trunk trunk = @remote.find { |b| b.strip == 'trunk' } if trunk @@ -94,14 +149,14 @@ def fix_trunk run_command("git branch -d -r trunk") end end - + def optimize_repos run_command("git gc") end - + def run_command(cmd) log "Running command: #{cmd}" - + IO.popen(cmd) do |stdout| stdout.each do |line| log line @@ -109,12 +164,16 @@ def run_command(cmd) end end - private - def log(msg) puts msg if @options[:verbose] end + def show_help_message(msg) + puts "Error starting script: #{msg}\n\n" + puts @opts.help + exit + end + end end From 072f7f8d66fb165f8a38d1c002e660bbf6fc6f20 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 17 Apr 2009 08:14:20 -0400 Subject: [PATCH 033/204] Fixed #21: No helpful error message when wrong args passed --- lib/svn2git/migration.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 2b34986..3b645c1 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -10,6 +10,7 @@ class Migration def initialize(args) @options = parse(args) + show_help_message("Missing SVN_URL parameter") if args.empty? show_help_message('Too many arguments') if args.size > 1 @url = args.first From 761dcbc6a302dc31f967ff987b42f6df3c82bd7b Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 17 Apr 2009 08:18:16 -0400 Subject: [PATCH 034/204] Updated docs for new command-line arg passing. Added notes on how to use verbose flag. --- README | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/README b/README index aa76d04..e065cc1 100644 --- a/README +++ b/README @@ -76,28 +76,28 @@ create a git repo from a svn repo in the specified layout. 1. The svn repo is in the standard layout of (trunk, branches, tags) at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo trunk=trunk branches=branches tags=tags + $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --branches branches --tags tags 2. The svn repo is NOT in standard layout and has only a trunk and tags at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo trunk=trunk tags=tags + $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --tags tags 3. The svn repo is NOT in standard layout and has only a trunk and branches at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo trunk=trunk branches=branches + $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --branches branches 4. The svn repo is NOT in standard layout and has only a trunk at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo trunk=trunk + $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk 5. The svn repo is NOT in standard layout and has no trunk, branches, or tags at the root level of the repo. Instead the root level of the repo is equivalent to the trunk and there are no tags or branches. - $ svn2git http://svn.yoursite.com/path/to/repo rootistrunk=true + $ svn2git http://svn.yoursite.com/path/to/repo --rootistrunk The above will create a git repository in the current directory with the git version of the svn repository. Hence, you need to make a directory that you @@ -118,9 +118,19 @@ system with the list of conversions to make, one per line, for example: Then pass an +authors+ option to +svn2git+ pointing to your file: - svn2git http://repos.com/myproject authors=~/authors.txt + svn2git http://repos.com/myproject --authors ~/authors.txt Alternatively, you can place the authors file into ~/.svn2git/authors and svn2git will load it out of there. This allows you to build up one authors file for all your projects and have it loaded for each repository that you -migrate. \ No newline at end of file +migrate. + +=== Debugging + +If you're having problems with converting your repository and you're not sure why, +try turning on verbose logging. This will print out more information from the +underlying git-svn process. + +You can turn on verbose logging with the '-v' or '--verbose' flags, like so: + + $ svn2git http://svn.yoursite.com/path/to/repo --verbose \ No newline at end of file From fd9b521e542f985ec3107b34cc5aef6bbd4b3844 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 17 Apr 2009 08:21:05 -0400 Subject: [PATCH 035/204] Trying to make the readme file show up appropriately in GitHub. --- README => README.doc | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.doc (100%) diff --git a/README b/README.doc similarity index 100% rename from README rename to README.doc From 253ab588b5c1e15b5933c3b0f98c25287630cfa7 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 17 Apr 2009 08:23:36 -0400 Subject: [PATCH 036/204] Oops. Used the wrong format extension. --- README.doc => README.markdown | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.doc => README.markdown (100%) diff --git a/README.doc b/README.markdown similarity index 100% rename from README.doc rename to README.markdown From 5b7cbbe0e0ee45af9ffeb24c7ae189c4c80a633e Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 17 Apr 2009 08:39:54 -0400 Subject: [PATCH 037/204] Better markdown formatting. --- README.markdown | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.markdown b/README.markdown index e065cc1..cd0bb2b 100644 --- a/README.markdown +++ b/README.markdown @@ -1,13 +1,15 @@ -== svn2git +svn2git +======= -+svn2git+ is a tiny utility for migrating projects from Subversion to Git +_svn2git_ is a tiny utility for migrating projects from Subversion to Git while keeping the trunk, branches and tags where they should be. It uses git-svn to clone an svn repository and does some clean-up to make sure branches and tags are imported in a meaningful way, and that the code checked into master ends up being what's currently in your svn trunk rather than whichever svn branch your last commit was in. -=== Examples +Examples +-------- Say I have this code in svn: @@ -59,14 +61,16 @@ After svn2git is done with your project, you'll get this instead: Finally, it makes sure the HEAD of master is the same as the current trunk of the svn repo. -=== Installation +Installation +------------ Make sure you have git installed, then install the gem: $ sudo apt-get install git-core git-svn $ sudo gem install svn2git -=== Usage +Usage +----- There are a number of ways in which you can create a git repo from an existing svn repo. The differentiating factor is the svn repo layout. Below is an @@ -108,7 +112,8 @@ specified trunk=foo branches=bar and tags=foobar it would be referencing http://svn.yoursite.com/path/to/repo/foo as your trunk, and so on. However, in case 5 it references the root of the repo as trunk. -=== Authors +Authors +------- To convert all your svn authors to git format, create a file somewhere on your system with the list of conversions to make, one per line, for example: @@ -125,7 +130,8 @@ svn2git will load it out of there. This allows you to build up one authors file for all your projects and have it loaded for each repository that you migrate. -=== Debugging +Debugging +--------- If you're having problems with converting your repository and you're not sure why, try turning on verbose logging. This will print out more information from the From 6d3f222ab9049050d9160df1c187253fd355ecee Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 17 Apr 2009 08:42:11 -0400 Subject: [PATCH 038/204] More doc improvements. --- README.markdown | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.markdown b/README.markdown index cd0bb2b..bce83e1 100644 --- a/README.markdown +++ b/README.markdown @@ -66,8 +66,8 @@ Installation Make sure you have git installed, then install the gem: - $ sudo apt-get install git-core git-svn - $ sudo gem install svn2git + $ sudo apt-get install git-core git-svn + $ sudo gem install nirvdrum-svn2git Usage ----- @@ -80,28 +80,28 @@ create a git repo from a svn repo in the specified layout. 1. The svn repo is in the standard layout of (trunk, branches, tags) at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --branches branches --tags tags + $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --branches branches --tags tags 2. The svn repo is NOT in standard layout and has only a trunk and tags at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --tags tags + $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --tags tags 3. The svn repo is NOT in standard layout and has only a trunk and branches at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --branches branches + $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --branches branches 4. The svn repo is NOT in standard layout and has only a trunk at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk + $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk 5. The svn repo is NOT in standard layout and has no trunk, branches, or tags at the root level of the repo. Instead the root level of the repo is equivalent to the trunk and there are no tags or branches. - $ svn2git http://svn.yoursite.com/path/to/repo --rootistrunk + $ svn2git http://svn.yoursite.com/path/to/repo --rootistrunk The above will create a git repository in the current directory with the git version of the svn repository. Hence, you need to make a directory that you From 1dcaae9f2f6ad32dc23a05089c64d802d549a13e Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 17 Apr 2009 09:01:14 -0400 Subject: [PATCH 039/204] Fixed #22: Add a changelog. --- ChangeLog.markdown | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ChangeLog.markdown diff --git a/ChangeLog.markdown b/ChangeLog.markdown new file mode 100644 index 0000000..b8abe5d --- /dev/null +++ b/ChangeLog.markdown @@ -0,0 +1,22 @@ +# 1.2.0 - 2009-04-17 + + * Reworked command-line options so they work similarly to every other app in the world. + * Better error messaging when no URL provided. + * Improved docs. + +# 1.1.1 - 2009-04-15 + + * Started using Jeweler for gem management. + * Fixed issue with not loading up RubyGems appropriately. + +# 1.1.0 - 2009-01-02 + + * First release since nirvdrum fork. + + * Fixed issues with handling of tags and branches. + * Added better logging of output from git-svn. + * Wrap external command processing to capture failures. + +# 1.0.0 - 2008-07-19 + + * Forked version from jcoglan. \ No newline at end of file From 9d408de5f8144ddf35d522cdf0f5b86f55d3abbf Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 17 Apr 2009 09:01:42 -0400 Subject: [PATCH 040/204] Version bump to 1.2.0 --- VERSION.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION.yml b/VERSION.yml index 5e83768..87f7f42 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- -:patch: 1 +:minor: 2 +:patch: 0 :major: 1 -:minor: 1 From 07f1edadd42a6b252c0ea675965924660981e294 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 17 Apr 2009 09:01:52 -0400 Subject: [PATCH 041/204] Regenerated gemspec for version 1.2.0 --- svn2git.gemspec | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 9c38c8c..e0c6338 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,18 +2,21 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "1.1.1" + s.version = "1.2.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2009-04-15} + s.date = %q{2009-04-17} s.default_executable = %q{svn2git} s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] s.extra_rdoc_files = [ - "README" + "ChangeLog.markdown", + "README.markdown" ] s.files = [ + "ChangeLog.markdown", + "README.markdown", "Rakefile", "VERSION.yml", "bin/svn2git", @@ -24,12 +27,12 @@ Gem::Specification.new do |s| s.homepage = %q{https://www.negativetwenty.net/redmine/projects/svn2git} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.1} + s.rubygems_version = %q{1.3.2} s.summary = %q{A tool for migrating svn projects to git} if s.respond_to? :specification_version then current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 + s.specification_version = 3 if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then else From 2612f80052c735c6190f014b4c60fe0a26c51c83 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 19 Apr 2009 19:28:57 -0400 Subject: [PATCH 042/204] Fixed broken svn2git binary. --- bin/svn2git | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/bin/svn2git b/bin/svn2git index aff089c..64551d8 100644 --- a/bin/svn2git +++ b/bin/svn2git @@ -25,13 +25,5 @@ gem 'svn2git' require 'svn2git' -url = ARGV.shift -options = ARGV.inject({}) do |memo, arg| - parts = arg.split('=') - memo[parts.first.to_sym] = parts.last - memo -end - -migration = Svn2Git::Migration.new(url, options) +migration = Svn2Git::Migration.new(ARGV) migration.run! - From f905d4beb7a4ef1520c413da825e92a77d113f1a Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 19 Apr 2009 19:29:08 -0400 Subject: [PATCH 043/204] Version bump to 1.2.1 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 87f7f42..88da7cd 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- :minor: 2 -:patch: 0 +:patch: 1 :major: 1 From 807ef64dce1c02152289a1e3e500353931c7062e Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 19 Apr 2009 19:29:13 -0400 Subject: [PATCH 044/204] Regenerated gemspec for version 1.2.1 --- svn2git.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index e0c6338..b84c8a9 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,11 +2,11 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "1.2.0" + s.version = "1.2.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2009-04-17} + s.date = %q{2009-04-19} s.default_executable = %q{svn2git} s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] From 4728ab2beddee0c7c825b9696a5c51c96544ab69 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 19 Apr 2009 19:30:18 -0400 Subject: [PATCH 045/204] Added release notes for the 1.2.1 release. --- ChangeLog.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index b8abe5d..fe66837 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,7 @@ +# 1.2.1 - 2009-04-19 + + * Fixed a problem with the svn2git binary not loading command-line args properly. + # 1.2.0 - 2009-04-17 * Reworked command-line options so they work similarly to every other app in the world. From c90618ff82a646f3752c88f30bbe530ddce99a2a Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Mon, 4 May 2009 13:36:13 -0400 Subject: [PATCH 046/204] Use the correct gem in the bin file. --- bin/svn2git | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/svn2git b/bin/svn2git index 64551d8..041c03f 100644 --- a/bin/svn2git +++ b/bin/svn2git @@ -21,7 +21,7 @@ # THE SOFTWARE. require 'rubygems' -gem 'svn2git' +gem 'nirvdrum-svn2git' require 'svn2git' From 660478eac1034d3928beb26135c884a418b7e1e9 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Mon, 4 May 2009 13:38:45 -0400 Subject: [PATCH 047/204] Version bump to 1.2.2 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 88da7cd..f981404 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- :minor: 2 -:patch: 1 +:patch: 2 :major: 1 From 36387558d560ddaff80c7758492b1d9bae8d66f3 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Mon, 4 May 2009 14:00:24 -0400 Subject: [PATCH 048/204] Manually applying patch by mss. Seems this isn't needed at all by RubyGems. --- bin/svn2git | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/svn2git b/bin/svn2git index 041c03f..7609e6d 100644 --- a/bin/svn2git +++ b/bin/svn2git @@ -20,9 +20,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -require 'rubygems' -gem 'nirvdrum-svn2git' - require 'svn2git' migration = Svn2Git::Migration.new(ARGV) From cf4d978ebce58d6477353400fcf4d8ef9bf3caf7 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Mon, 4 May 2009 14:00:37 -0400 Subject: [PATCH 049/204] Version bump to 1.2.3 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index f981404..77fe9d1 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- :minor: 2 -:patch: 2 +:patch: 3 :major: 1 From 91edcb246d90025ee4a6b3c1a929043448bb5c2d Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Mon, 4 May 2009 14:16:51 -0400 Subject: [PATCH 050/204] Version bump to 1.2.4 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 77fe9d1..b2f17af 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- :minor: 2 -:patch: 3 +:patch: 4 :major: 1 From 5e151aa0d066e372fe78206ca3b539c7ca20be66 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Mon, 4 May 2009 14:19:02 -0400 Subject: [PATCH 051/204] Regenerated gemspec for version 1.2.4 --- svn2git.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index b84c8a9..3a1caf2 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,11 +2,11 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "1.2.1" + s.version = "1.2.4" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2009-04-19} + s.date = %q{2009-05-04} s.default_executable = %q{svn2git} s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] From f62b5d03baee208fc2060587925ad9f47a5a7f36 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Mon, 4 May 2009 14:21:27 -0400 Subject: [PATCH 052/204] Updated changelog. --- ChangeLog.markdown | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index fe66837..25ef9c2 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,15 @@ +# 1.2.4 - 2009-05-04 + + * No changes. I ran the jeweler command twice inadvertently. Tearing down the release would be more harmful than helpful. + +# 1.2.3 - 2009-05-04 + + * Yanked out the code referencing the gem by name. This shouldn't be necessary at all. + +# 1.2.2 - 2009-05-04 + + * Updated the reference gem in the binary to use this one and not the one on RubyForge. + # 1.2.1 - 2009-04-19 * Fixed a problem with the svn2git binary not loading command-line args properly. From 3819a9da98d3d007ae67cc9a8354ee2c0f5dc812 Mon Sep 17 00:00:00 2001 From: Andrew De Ponte Date: Mon, 11 May 2009 12:06:32 -0700 Subject: [PATCH 053/204] Added FAQ section to README. --- README.markdown | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index bce83e1..9e62e9e 100644 --- a/README.markdown +++ b/README.markdown @@ -139,4 +139,34 @@ underlying git-svn process. You can turn on verbose logging with the '-v' or '--verbose' flags, like so: - $ svn2git http://svn.yoursite.com/path/to/repo --verbose \ No newline at end of file + $ svn2git http://svn.yoursite.com/path/to/repo --verbose + +FAQ +--- + +1. Why don't the tags show up in the master branch? + + The tags won't show up in the master branch because the tags are actually + tied to the commits that were created in svn when the user made the tag. + Those commits are the first (head) commit of branch in svn that is + associated with that tag. If you want to see all the branches and tags + and their relationships in gitk you can run the following: gitk --all + + For further details please refer to FAQ #2. + +2. Why don't you reference the parent of the tag commits instead? + + In svn you are forced to create what are known in git as annotated tags. + It just so happens that svn annotated tags allow you to commit change + sets along with the tagging action. This means that the svn annotated tag + is a bit more complex then just an annotated tag it is a commit which is + treated as an annotated tag. Hence, for there to be a true 1-to-1 mapping + between git and svn we have to transfer over the svn commit which acts as + an annotated tag and then tag that commit in git using an annotated tag. + + If we were to reference the parent of this svn tagged commit there could + potentially be situations where a developer would checkout a tag in git + and the resulting code base would be different then if they checked out + 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. \ No newline at end of file From 6597ca56dc46a4069940772f1225b3b9b3466049 Mon Sep 17 00:00:00 2001 From: "Malte S. Stretz" Date: Wed, 6 May 2009 16:52:04 +0800 Subject: [PATCH 054/204] Description of --rootistrunk missed a space Signed-off-by: Kevin Menard --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 3b645c1..3fd8ab1 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -61,7 +61,7 @@ def parse(args) options[:authors] = authors end - opts.on('--rootistrunk', 'Use this if the root level of the repo isequivalent to the trunk and there are no tags or branches') do + 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 end From 577e9088548401ef03dc98b284d8e3e842781398 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 22 May 2009 08:09:11 -0400 Subject: [PATCH 055/204] Added myself as a copyright holder. --- MIT-LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MIT-LICENSE b/MIT-LICENSE index 714d101..94f6821 100644 --- a/MIT-LICENSE +++ b/MIT-LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2008 James Coglan +Copyright (c) 2008 James Coglan, Kevin Menard Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 172df081c9d253cbf2333559c3d4de207b13fd2a Mon Sep 17 00:00:00 2001 From: "Malte S. Stretz" Date: Wed, 6 May 2009 12:30:55 +0200 Subject: [PATCH 056/204] Fix backdating of tags This probably never worked: * There was a typo in GIT_COMMITTER_DATE * export'd environment is local to the shell and doesn't stick around * And if it did, this would break any later commits $ for x in broken fixed; \ do cd test.$x; \ ts=$(git cat-file tag 0.1 | sed -e '/^tagger/!d;s/^.*> \([^ ]*\).*$/\1/'); \ ruby -e 'puts "'$x':\t" + Time.at('$ts').strftime("%Y-%m-%d")'; \ cd ..; \ done broken: 2009-05-06 fixed: 2009-02-16 --- lib/svn2git/migration.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 3fd8ab1..bed5e79 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -125,8 +125,7 @@ def fix_tags id = tag.strip.gsub(%r{^#{@options[:tags]}\/}, '') subject = `git log -1 --pretty=format:"%s" #{tag.strip()}` date = `git log -1 --pretty=format:"%ci" #{tag.strip()}` - `export GIT_COMMITER_DATE="#{date}"` - run_command("git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}'") + run_command("GIT_COMMITTER_DATE='#{date}' git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}'") run_command("git branch -d -r #{tag.strip()}") end end From 3399a80d62180042354f9e9bbe1d2b36ce314b78 Mon Sep 17 00:00:00 2001 From: "Malte S. Stretz" Date: Wed, 6 May 2009 15:03:04 +0200 Subject: [PATCH 057/204] Introducing --exclude to filter paths from the import --- README.markdown | 5 +++++ lib/svn2git/migration.rb | 22 +++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 9e62e9e..3ddd226 100644 --- a/README.markdown +++ b/README.markdown @@ -103,6 +103,11 @@ equivalent to the trunk and there are no tags or branches. $ svn2git http://svn.yoursite.com/path/to/repo --rootistrunk +6. The svn repo is in the standard layout but you want to exclude the massive +doc directory and the backup files you once accidently added. + + $ svn2git http://svn.example.com/path/to/repo --exclude doc --exclude '.*~$' + The above will create a git repository in the current directory with the git version of the svn repository. Hence, you need to make a directory that you want your new git repo to exist in, change into it and then run one of the diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index bed5e79..8ac0dc9 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -32,6 +32,7 @@ def parse(args) options[:trunk] = 'trunk' options[:branches] = 'branches' options[:tags] = 'tags' + options[:exclude] = [] if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE)) options[:authors] = DEFAULT_AUTHORS_FILE @@ -65,6 +66,10 @@ def parse(args) options[:rootistrunk] = true end + opts.on('--exclude REGEX', 'Specify a Perl regular expression to filter paths when fetching; can be used multiple times') do |regex| + options[:exclude] << regex + end + opts.on('-v', '--verbose', 'Be verbose in logging -- useful for debugging issues') do options[:verbose] = true end @@ -91,6 +96,7 @@ def clone! tags = @options[:tags] rootistrunk = @options[:rootistrunk] authors = @options[:authors] + exclude = @options[:exclude] if rootistrunk # Non-standard repository layout. The repository root is effectively 'trunk.' @@ -110,7 +116,21 @@ def clone! end run_command("git config svn.authorsfile #{authors}") if authors - run_command("git svn fetch") + + cmd = "git svn fetch" + unless exclude.empty? + # Add exclude paths to the command line; some versions of git support + # this for fetch only, later also for init. + regex = [] + unless rootistrunk + regex << "#{trunk}[/]" unless trunk.nil? + regex << "#{tags}[/][^/]+[/]" unless tags.nil? + regex << "#{branches}[/][^/]+[/]" unless branches.nil? + end + regex = '^(?:' + regex.join('|') + ')(?:' + exclude.join('|') + ')' + cmd += "'--ignore-paths=#{regex}'" + end + run_command(cmd) get_branches end From f97ae98af01b144d722cdc31fe5d8886943fc8c7 Mon Sep 17 00:00:00 2001 From: "Malte S. Stretz" Date: Wed, 6 May 2009 15:19:10 +0200 Subject: [PATCH 058/204] Introduce --no{trunk,branches,tags} switches to fulfil the promises of the README --- README.markdown | 23 +++++++++-------------- lib/svn2git/migration.rb | 24 +++++++++++++++++++----- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/README.markdown b/README.markdown index 3ddd226..34a610d 100644 --- a/README.markdown +++ b/README.markdown @@ -80,30 +80,25 @@ create a git repo from a svn repo in the specified layout. 1. The svn repo is in the standard layout of (trunk, branches, tags) at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --branches branches --tags tags + $ svn2git http://svn.example.com/path/to/repo 2. The svn repo is NOT in standard layout and has only a trunk and tags at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --tags tags + $ svn2git http://svn.example.com/path/to/repo --trunk dev --tags rel --nobranches -3. The svn repo is NOT in standard layout and has only a trunk and branches at -the root level of the repo. - - $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk --branches branches - -4. The svn repo is NOT in standard layout and has only a trunk at the root +3. The svn repo is NOT in standard layout and has only a trunk at the root level of the repo. - $ svn2git http://svn.yoursite.com/path/to/repo --trunk trunk + $ svn2git http://svn.example.com/path/to/repo --trunk trunk --nobranches --notags -5. The svn repo is NOT in standard layout and has no trunk, branches, or tags +4. The svn repo is NOT in standard layout and has no trunk, branches, or tags at the root level of the repo. Instead the root level of the repo is equivalent to the trunk and there are no tags or branches. - $ svn2git http://svn.yoursite.com/path/to/repo --rootistrunk + $ svn2git http://svn.example.com/path/to/repo --rootistrunk -6. The svn repo is in the standard layout but you want to exclude the massive +5. The svn repo is in the standard layout but you want to exclude the massive doc directory and the backup files you once accidently added. $ svn2git http://svn.example.com/path/to/repo --exclude doc --exclude '.*~$' @@ -114,8 +109,8 @@ want your new git repo to exist in, change into it and then run one of the above commands. Note that in the above cases the trunk, branches, tags options are simply folder names relative to the provided repo path. For example if you specified trunk=foo branches=bar and tags=foobar it would be referencing -http://svn.yoursite.com/path/to/repo/foo as your trunk, and so on. However, in -case 5 it references the root of the repo as trunk. +http://svn.example.com/path/to/repo/foo as your trunk, and so on. However, in +case 4 it references the root of the repo as trunk. Authors ------- diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 8ac0dc9..494f783 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -53,17 +53,31 @@ def parse(args) opts.on('--branches BRANCHES_PATH', 'Subpath to branches from repository URL (default: branches)') do |branches| options[:branches] = branches end - opts.on('--tags TAGS_PATH', 'Subpath to tags from repository URL (default: tags)') do |tags| options[:tags] = tags end - opts.on('--authors AUTHORS_FILE', "Path to file containing svn-to-git authors mapping (default: #{DEFAULT_AUTHORS_FILE})") do |authors| - options[:authors] = authors - 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 + options[:branches] = nil + options[:tags] = nil + end + + opts.on('--notrunk', 'Do not import anything from trunk') do + options[:trunk] = nil + end + + opts.on('--nobranches', 'Do not try to import any branches') do + options[:branches] = nil + end + + opts.on('--notags', 'Do not try to import any tags') do + options[:tags] = nil + end + + opts.on('--authors AUTHORS_FILE', "Path to file containing svn-to-git authors mapping (default: #{DEFAULT_AUTHORS_FILE})") do |authors| + options[:authors] = authors end opts.on('--exclude REGEX', 'Specify a Perl regular expression to filter paths when fetching; can be used multiple times') do |regex| From 210e0722e0649e79ae4f32f2c0ce41f5427a6951 Mon Sep 17 00:00:00 2001 From: "Malte S. Stretz" Date: Wed, 6 May 2009 13:40:37 +0200 Subject: [PATCH 059/204] Fix up markdown code blocks and examples --- README.markdown | 76 ++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/README.markdown b/README.markdown index 34a610d..7021036 100644 --- a/README.markdown +++ b/README.markdown @@ -13,50 +13,50 @@ Examples Say I have this code in svn: - trunk - ... - branches - 1.x - 2.x - tags - 1.0.0 - 1.0.1 - 1.0.2 - 1.1.0 - 2.0.0 + trunk + ... + branches + 1.x + 2.x + tags + 1.0.0 + 1.0.1 + 1.0.2 + 1.1.0 + 2.0.0 git-svn will go through the commit history to build a new git repo. It will import all branches and tags as remote svn branches, whereas what you really want is git-native local branches and git tag objects. So after importing this project I'll get: - $ git branch - * master - $ git branch -a - * master - 1.x - 2.x - tags/1.0.0 - tags/1.0.1 - tags/1.0.2 - tags/1.1.0 - tags/2.0.0 - trunk - $ git tag -l - [ empty ] + $ git branch + * master + $ git branch -a + * master + 1.x + 2.x + tags/1.0.0 + tags/1.0.1 + tags/1.0.2 + tags/1.1.0 + tags/2.0.0 + trunk + $ git tag -l + [ empty ] After svn2git is done with your project, you'll get this instead: - $ git branch - * master - 1.x - 2.x - $ git tag -l - 1.0.0 - 1.0.1 - 1.0.2 - 1.1.0 - 2.0.0 + $ git branch + * master + 1.x + 2.x + $ git tag -l + 1.0.0 + 1.0.1 + 1.0.2 + 1.1.0 + 2.0.0 Finally, it makes sure the HEAD of master is the same as the current trunk of the svn repo. @@ -118,12 +118,12 @@ Authors To convert all your svn authors to git format, create a file somewhere on your system with the list of conversions to make, one per line, for example: - jcoglan = James Coglan - stnick = Santa Claus + jcoglan = James Coglan + stnick = Santa Claus Then pass an +authors+ option to +svn2git+ pointing to your file: - svn2git http://repos.com/myproject --authors ~/authors.txt + $ svn2git http://svn.example.com/path/to/repo --authors ~/authors.txt Alternatively, you can place the authors file into ~/.svn2git/authors and svn2git will load it out of there. This allows you to build up one authors From 4561ce2596eadf66175252647301ea0800973991 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 9 Jun 2009 19:58:47 -0400 Subject: [PATCH 060/204] Fixed a code block issue. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 7021036..13d79bb 100644 --- a/README.markdown +++ b/README.markdown @@ -139,7 +139,7 @@ underlying git-svn process. You can turn on verbose logging with the '-v' or '--verbose' flags, like so: - $ svn2git http://svn.yoursite.com/path/to/repo --verbose + $ svn2git http://svn.yoursite.com/path/to/repo --verbose FAQ --- From dd5984d90765b26145711bf2a9a6486340263e1c Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 9 Jun 2009 20:00:56 -0400 Subject: [PATCH 061/204] Updated changelog. --- ChangeLog.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 25ef9c2..9a5dc03 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,12 @@ +# 1.3.0 - 2009-05-06 + + Many thanks to mss for the patches making up most of this release. + + * Fixed a problem where tags didn't get the original date and time. + * New switch --exclude which can be used to specify a PCRE pattern to exclude paths from the import. + * New switches --no{trunk,branches,tags} to skip import of those. + * Improved docs. + # 1.2.4 - 2009-05-04 * No changes. I ran the jeweler command twice inadvertently. Tearing down the release would be more harmful than helpful. From 9c772a46ebe0a21fb14647b7bd7bcfbd6257db80 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 9 Jun 2009 20:01:37 -0400 Subject: [PATCH 062/204] Wrong date in changelog. --- ChangeLog.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 9a5dc03..013d634 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,4 +1,4 @@ -# 1.3.0 - 2009-05-06 +# 1.3.0 - 2009-06-09 Many thanks to mss for the patches making up most of this release. From 218ce20ab1e1d55ca45f4892c367854be3dc16ed Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 9 Jun 2009 20:02:10 -0400 Subject: [PATCH 063/204] Version bump to 1.3.0 --- VERSION.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION.yml b/VERSION.yml index b2f17af..5d7b9ff 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- -:minor: 2 -:patch: 4 +:minor: 3 +:patch: 0 :major: 1 From b66908b2010422486bf38b0345eb13cbfd9c5adc Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 9 Jun 2009 20:02:25 -0400 Subject: [PATCH 064/204] Regenerated gemspec for version 1.3.0 --- svn2git.gemspec | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 3a1caf2..4de7a79 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,32 +2,34 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "1.2.4" + s.version = "1.3.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2009-05-04} + s.date = %q{2009-06-09} s.default_executable = %q{svn2git} s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] s.extra_rdoc_files = [ "ChangeLog.markdown", - "README.markdown" + "README.markdown" ] s.files = [ - "ChangeLog.markdown", - "README.markdown", - "Rakefile", - "VERSION.yml", - "bin/svn2git", - "lib/svn2git.rb", - "lib/svn2git/migration.rb" + ".gitignore", + "ChangeLog.markdown", + "MIT-LICENSE", + "README.markdown", + "Rakefile", + "VERSION.yml", + "bin/svn2git", + "lib/svn2git.rb", + "lib/svn2git/migration.rb", + "svn2git.gemspec" ] - s.has_rdoc = true s.homepage = %q{https://www.negativetwenty.net/redmine/projects/svn2git} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.2} + s.rubygems_version = %q{1.3.4} s.summary = %q{A tool for migrating svn projects to git} if s.respond_to? :specification_version then From b1b7fa322d741c7b2c1aa1e2b219aa7d3bb28e58 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 9 Jun 2009 20:31:15 -0400 Subject: [PATCH 065/204] Reverted a change added by iteman. --- bin/svn2git | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/svn2git b/bin/svn2git index 64551d8..7609e6d 100644 --- a/bin/svn2git +++ b/bin/svn2git @@ -20,9 +20,6 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -require 'rubygems' -gem 'svn2git' - require 'svn2git' migration = Svn2Git::Migration.new(ARGV) From 98bdf7885ed20710130b84f2f06046d45ab77051 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 9 Jun 2009 20:35:22 -0400 Subject: [PATCH 066/204] Version bump to 1.3.1 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 5d7b9ff..4d65957 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- :minor: 3 -:patch: 0 +:patch: 1 :major: 1 From 6891794e776dcefa695b5f9cfd7556393ba9f11a Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 9 Jun 2009 20:37:08 -0400 Subject: [PATCH 067/204] Release notes for 1.3.1 --- ChangeLog.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 013d634..ce7c3a6 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,9 @@ +# 1.3.1 - 2009-06-09 + + Thanks to iteman for finding a problem with the tagging process and providing a patch. + + * Fixed a problem with creating actual git tags when the SVN tags path was named anything other than 'tags.' + # 1.3.0 - 2009-06-09 Many thanks to mss for the patches making up most of this release. From bb196c839e0dc59491d4c3a0249bac6ec48a6da6 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 9 Jun 2009 20:38:54 -0400 Subject: [PATCH 068/204] Regenerated gemspec for version 1.3.1 --- svn2git.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 4de7a79..07f36bc 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "1.3.0" + s.version = "1.3.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] From 51563026fbc33e4991cfe4759df462c3a8d4db09 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 26 Jun 2009 19:19:35 -0400 Subject: [PATCH 069/204] Don't backtick commands anywhere. --- lib/svn2git/migration.rb | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 0cd17d5..adc35e0 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -129,7 +129,7 @@ def clone! run_command(cmd) end - run_command("git config svn.authorsfile #{authors}") if authors + run_command("git config svn.authorsfile #{authors}") unless authors.nil? cmd = "git svn fetch" unless exclude.empty? @@ -150,7 +150,8 @@ def clone! end def get_branches - @remote = `git branch -r`.split(/\n/) + @local = run_command("git branch -l").split(/\n/).collect{ |b| b.strip } + @remote = run_command("git branch -r").split(/\n/).collect{ |b| b.strip } @tags = @remote.find_all { |b| b.strip =~ %r{^tags\/} } end @@ -169,8 +170,18 @@ def fix_branches svn_branches.each do |branch| branch = branch.strip next if branch == 'trunk' - run_command("git checkout #{branch}") - run_command("git checkout -b #{branch}") + + if branch =~ /origin\/(.*)/ + log "Skipping branch '#{branch}' because it is a remote git branch, not a remote SVN branch." + next + end + + if @local.include? branch + run_command("git checkout #{branch}") + run_command("git svn rebase") + else + run_command("git checkout -b #{branch}") + end end end @@ -191,11 +202,16 @@ def optimize_repos def run_command(cmd) log "Running command: #{cmd}" + ret = '' + IO.popen(cmd) do |stdout| stdout.each do |line| log line + ret << line end end + + ret end def log(msg) From 7a4664a5cf3a5e4071c4c10ec2442bca36ba7e38 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 26 Jun 2009 19:35:24 -0400 Subject: [PATCH 070/204] Really remove all uses of backticks this time. --- lib/svn2git/migration.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index adc35e0..da90c70 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -157,11 +157,12 @@ def get_branches def fix_tags @tags.each do |tag| - id = tag.strip.gsub(%r{^tags\/}, '') - subject = `git log -1 --pretty=format:"%s" #{tag.strip()}` - date = `git log -1 --pretty=format:"%ci" #{tag.strip()}` - run_command("GIT_COMMITTER_DATE='#{date}' git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}'") - run_command("git branch -d -r #{tag.strip()}") + tag = tag.strip + id = tag.strip.gsub(%r{^tags\/}, '').strip + subject = run_command("git log -1 --pretty=format:'%s' #{tag}") + date = run_command("git log -1 --pretty=format:'%ci' #{tag}") + run_command("GIT_COMMITTER_DATE='#{date}' git tag -a -m '#{subject}' '#{id}' '#{tag}'") + run_command("git branch -d -r #{tag}") end end From 77e8f31374efbbf2749236316656d125a68d2b4c Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 26 Jun 2009 19:35:52 -0400 Subject: [PATCH 071/204] Don't add RubyMine project files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 5fff1d9..677619f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ pkg +.idea From 83f3e8a5be84b006ee2b366afdcaae455f861aa6 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 26 Jun 2009 19:37:51 -0400 Subject: [PATCH 072/204] Backed out a bad change. This should have been on its own branch. --- lib/svn2git/migration.rb | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index da90c70..24bff42 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -171,18 +171,9 @@ def fix_branches svn_branches.each do |branch| branch = branch.strip next if branch == 'trunk' - - if branch =~ /origin\/(.*)/ - log "Skipping branch '#{branch}' because it is a remote git branch, not a remote SVN branch." - next - end - - if @local.include? branch - run_command("git checkout #{branch}") - run_command("git svn rebase") - else - run_command("git checkout -b #{branch}") - end + + run_command("git checkout #{branch}") + run_command("git checkout -b #{branch}") end end From 65eeed19c6e7a3280ba80bf3907bad4130255c61 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 20 Oct 2009 22:12:33 -0400 Subject: [PATCH 073/204] Updated readme with gemcutter info. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 13d79bb..12a2eb7 100644 --- a/README.markdown +++ b/README.markdown @@ -67,7 +67,7 @@ Installation Make sure you have git installed, then install the gem: $ sudo apt-get install git-core git-svn - $ sudo gem install nirvdrum-svn2git + $ sudo gem install svn2git --source http://gemcutter.org [formerly: $ sudo gem install nirvdrum-svn2git --source http://gems.github.com] Usage ----- From ab0f5e77a59192bbc3ef0712a95b2241831e66e7 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 20 Oct 2009 22:15:10 -0400 Subject: [PATCH 074/204] Added more context for the gemcutter move. --- README.markdown | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 12a2eb7..8c486b7 100644 --- a/README.markdown +++ b/README.markdown @@ -67,7 +67,9 @@ Installation Make sure you have git installed, then install the gem: $ sudo apt-get install git-core git-svn - $ sudo gem install svn2git --source http://gemcutter.org [formerly: $ sudo gem install nirvdrum-svn2git --source http://gems.github.com] + $ sudo gem install svn2git --source http://gemcutter.org + +*NB: Previous versions of the gem could be installed from GitHub as nirvdrum-svn2git. You can install that gem via `$ sudo gem install nirvdrum-svn2git --source http://gems.github.com`, but the nirvdrum-svn2git gem will no longer be updated. Please use the one hosted on gemcutter.* Usage ----- From 4b29515a66f4ae715403dbe3d892438fee31145a Mon Sep 17 00:00:00 2001 From: Andrew De Ponte Date: Thu, 3 Dec 2009 18:46:16 -0800 Subject: [PATCH 075/204] Added a little helper line to get people started with authors file. --- README.markdown | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.markdown b/README.markdown index 8c486b7..e2d69bb 100644 --- a/README.markdown +++ b/README.markdown @@ -132,6 +132,17 @@ svn2git will load it out of there. This allows you to build up one authors file for all your projects and have it loaded for each repository that you migrate. +If you need a jump start on figuring out what users made changes in your +svn repositories the following command sequence might help. It grabs all +the logs from the svn repository, pulls out all the names from the commits, +sorts them, and then reduces the list to only unique names. So, in the end +it outputs a list of usernames of the people that made commits to the svn +repository which name on its own line. This would allow you to easily +redirect the output of this command sequence to ~/.svn2git/authors and have +a very good starting point for your mapping. + + $ svn log | grep -E "r[0-9]+ \| [a-z]+ \|" | awk '{print $3}' | sort | uniq + Debugging --------- From 3ce9cc1e21a14dfeddc382f36d88bbc6ae9d556b Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Thu, 24 Dec 2009 16:18:16 +0800 Subject: [PATCH 076/204] Add note about installing Ruby and rubygems. --- README.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index e2d69bb..2b3b1dd 100644 --- a/README.markdown +++ b/README.markdown @@ -64,9 +64,9 @@ the svn repo. Installation ------------ -Make sure you have git installed, then install the gem: +Make sure you have git, ruby and rubygems installed, then install the gem: - $ sudo apt-get install git-core git-svn + $ sudo apt-get install git-core git-svn ruby rubygems $ sudo gem install svn2git --source http://gemcutter.org *NB: Previous versions of the gem could be installed from GitHub as nirvdrum-svn2git. You can install that gem via `$ sudo gem install nirvdrum-svn2git --source http://gems.github.com`, but the nirvdrum-svn2git gem will no longer be updated. Please use the one hosted on gemcutter.* @@ -182,4 +182,4 @@ FAQ and the resulting code base would be different then if they checked out 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. \ No newline at end of file + tags. From 87c0fb22beda3d243c064d580fab9d0ce64f8c2b Mon Sep 17 00:00:00 2001 From: Rajit Singh Date: Thu, 11 Mar 2010 15:07:49 +0000 Subject: [PATCH 077/204] Deal cleanly with any single quotes found in tag comments so that the 'git tag' commands run correctly Bump versions --- ChangeLog.markdown | 6 +++++- VERSION.yml | 2 +- lib/svn2git/migration.rb | 11 +++++++++-- svn2git.gemspec | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index ce7c3a6..336a393 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,7 @@ +# 1.3.2 - 2010-03-11 + + * Deal cleanly with any single quotes found in tag comments so that the 'git tag' commands run correctly + # 1.3.1 - 2009-06-09 Thanks to iteman for finding a problem with the tagging process and providing a patch. @@ -50,4 +54,4 @@ # 1.0.0 - 2008-07-19 - * Forked version from jcoglan. \ No newline at end of file + * Forked version from jcoglan. diff --git a/VERSION.yml b/VERSION.yml index 4d65957..8387f73 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,4 @@ --- :minor: 3 -:patch: 1 +:patch: 2 :major: 1 diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 24bff42..55f1e5c 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -158,10 +158,13 @@ def get_branches def fix_tags @tags.each do |tag| tag = tag.strip - id = tag.strip.gsub(%r{^tags\/}, '').strip + id = tag.gsub(%r{^tags\/}, '').strip subject = run_command("git log -1 --pretty=format:'%s' #{tag}") date = run_command("git log -1 --pretty=format:'%ci' #{tag}") - run_command("GIT_COMMITTER_DATE='#{date}' git tag -a -m '#{subject}' '#{id}' '#{tag}'") + subject = escape_quotes(subject) + date = escape_quotes(date) + id = escape_quotes(id) + run_command("GIT_COMMITTER_DATE='#{date}' git tag -a -m '#{subject}' '#{id}' '#{escape_quotes(tag)}'") run_command("git branch -d -r #{tag}") end end @@ -216,6 +219,10 @@ def show_help_message(msg) exit end + def escape_quotes(str) + str.gsub("'", "'\\\\''") + end + end end diff --git a/svn2git.gemspec b/svn2git.gemspec index 07f36bc..0efbfa5 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "1.3.1" + s.version = "1.3.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] From 15c53b470f0c234c5ea9899fb821088e0b24b75b Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 12 Mar 2010 11:49:32 -0500 Subject: [PATCH 078/204] Provided proper attribution. --- ChangeLog.markdown | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 336a393..0e871ca 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,4 +1,7 @@ -# 1.3.2 - 2010-03-11 +# 1.3.2 - 2010-03-12 + + Thanks to rajit for finding a problem with quoting in tag comments that were causing issues with svn2git's internal + quoting and providing a patch. * Deal cleanly with any single quotes found in tag comments so that the 'git tag' commands run correctly From 2d8929af448993353416bd1af0183bcb2aa232c8 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 12 Mar 2010 11:50:16 -0500 Subject: [PATCH 079/204] Regenerated gemspec for version 1.3.2 --- svn2git.gemspec | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 0efbfa5..836fb07 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -1,3 +1,6 @@ +# Generated by jeweler +# DO NOT EDIT THIS FILE DIRECTLY +# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command # -*- encoding: utf-8 -*- Gem::Specification.new do |s| @@ -6,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2009-06-09} + s.date = %q{2010-03-12} s.default_executable = %q{svn2git} s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] @@ -29,7 +32,7 @@ Gem::Specification.new do |s| s.homepage = %q{https://www.negativetwenty.net/redmine/projects/svn2git} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.4} + s.rubygems_version = %q{1.3.6} s.summary = %q{A tool for migrating svn projects to git} if s.respond_to? :specification_version then @@ -42,3 +45,4 @@ Gem::Specification.new do |s| else end end + From 955e20e38155abdc5d4dabf5e32dff8156f129ba Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 12 Mar 2010 11:53:09 -0500 Subject: [PATCH 080/204] Set up gemcutter tasks for jeweler. --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index 2e5095c..00d41e2 100644 --- a/Rakefile +++ b/Rakefile @@ -10,6 +10,7 @@ begin spec.homepage = "https://www.negativetwenty.net/redmine/projects/svn2git" spec.email = "nirvdrum@gmail.com" end + Jeweler::GemcutterTasks.new rescue LoadError puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" From 3462800e0b7d69d590649e8c16c29471f3459d5c Mon Sep 17 00:00:00 2001 From: Jeff Ramnani Date: Wed, 31 Mar 2010 13:51:14 -0500 Subject: [PATCH 081/204] Fix error when using '--exclude' option. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 55f1e5c..4ac2f97 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -142,7 +142,7 @@ def clone! regex << "#{branches}[/][^/]+[/]" unless branches.nil? end regex = '^(?:' + regex.join('|') + ')(?:' + exclude.join('|') + ')' - cmd += "'--ignore-paths=#{regex}'" + cmd += " '--ignore-paths=#{regex}'" end run_command(cmd) From 0562f71693f37d9e4dc892930fe885f7982bc9c6 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 31 Mar 2010 19:23:27 -0400 Subject: [PATCH 082/204] Update changelog for 1.3.3 release and cleaned up attribution lines. --- ChangeLog.markdown | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 0e871ca..0c6f26b 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,19 +1,25 @@ +# 1.3.3 - 2010-03-31 + + Thanks to Jeff Ramnani (jramnani) for finding a problem with with the --excludes tag and providing a patch. + + * Fix error when using '--exclude' option. + # 1.3.2 - 2010-03-12 - Thanks to rajit for finding a problem with quoting in tag comments that were causing issues with svn2git's internal + Thanks to Rajit Singh (rajit) for finding a problem with quoting in tag comments that were causing issues with svn2git's internal quoting and providing a patch. - * Deal cleanly with any single quotes found in tag comments so that the 'git tag' commands run correctly + * Deal cleanly with any single quotes found in tag comments so that the 'git tag' commands run correctly. # 1.3.1 - 2009-06-09 - Thanks to iteman for finding a problem with the tagging process and providing a patch. + Thanks to KUBO Atsuhiro (iteman) for finding a problem with the tagging process and providing a patch. * Fixed a problem with creating actual git tags when the SVN tags path was named anything other than 'tags.' # 1.3.0 - 2009-06-09 - Many thanks to mss for the patches making up most of this release. + Many thanks to Malte S. Stretz (mss) for the patches making up most of this release. * Fixed a problem where tags didn't get the original date and time. * New switch --exclude which can be used to specify a PCRE pattern to exclude paths from the import. From 8022783ef1c5616adf7587ba391be70fdce898bb Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 31 Mar 2010 19:23:54 -0400 Subject: [PATCH 083/204] Version bump to 1.3.3 --- VERSION.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 8387f73..f638155 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,4 +1,5 @@ --- :minor: 3 -:patch: 2 +:build: +:patch: 3 :major: 1 From aa2ef131be6758b2c51ea28c49dbc431ad32d774 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 31 Mar 2010 19:24:32 -0400 Subject: [PATCH 084/204] Regenerated gemspec for version 1.3.3 --- svn2git.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 836fb07..c1b8fa6 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "1.3.2" + s.version = "1.3.3" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2010-03-12} + s.date = %q{2010-03-31} s.default_executable = %q{svn2git} s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] From 0ab29fc273a295a2220f228f7a14eec9bb3c5df0 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 26 Jun 2009 20:21:30 -0400 Subject: [PATCH 085/204] Clean up the branch listings a bit more. --- lib/svn2git/migration.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 4ac2f97..77b1aac 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -150,8 +150,12 @@ def clone! end def get_branches - @local = run_command("git branch -l").split(/\n/).collect{ |b| b.strip } - @remote = run_command("git branch -r").split(/\n/).collect{ |b| b.strip } + # Get the list of local and remote branches, taking care to ignore console color codes and ignoring the + # '*' character used to indicate the currently selected branch. + @local = run_command("git branch -l --no-color").split(/\n/).collect{ |b| b.gsub(/\*/,'').strip } + @remote = run_command("git branch -r --no-color").split(/\n/).collect{ |b| b.gsub(/\*/,'').strip } + + # Tags are remote branches that start with "tags/". @tags = @remote.find_all { |b| b.strip =~ %r{^tags\/} } end From 78a7981cbbebfd0b9f27f388143d7e30f4a09e14 Mon Sep 17 00:00:00 2001 From: Nathaniel McCallum Date: Thu, 27 May 2010 12:54:18 -0400 Subject: [PATCH 086/204] add rebase option --- lib/svn2git/migration.rb | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 77b1aac..7d5129c 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -10,14 +10,21 @@ class Migration def initialize(args) @options = parse(args) - show_help_message("Missing SVN_URL parameter") if args.empty? - show_help_message('Too many arguments') if args.size > 1 - - @url = args.first + if @options.fetch(:rebase, false) + show_help_message('Too many arguments') if args.size > 0 + else + show_help_message("Missing SVN_URL parameter") if args.empty? + show_help_message('Too many arguments') if args.size > 1 + @url = args.first + end end def run! - clone! + if @options.fetch(:rebase, false) + get_branches + else + clone! + end fix_tags fix_branches fix_trunk @@ -46,6 +53,10 @@ def parse(args) opts.separator '' opts.separator 'Specific options:' + opts.on('--rebase', 'Instead of cloning a new project, rebase an existing one against svn') do + options[:rebase] = true + end + opts.on('--trunk TRUNK_PATH', 'Subpath to trunk from repository URL (default: trunk)') do |trunk| options[:trunk] = trunk end @@ -177,20 +188,28 @@ def fix_branches svn_branches = @remote.find_all { |b| not @tags.include?(b) } svn_branches.each do |branch| branch = branch.strip - next if branch == 'trunk' + if @options.fetch(:rebase, false) and (@local.index(branch) != nil or branch == 'trunk') + branch = 'master' if branch == 'trunk' + run_command("git checkout -f #{branch}") + run_command("git svn rebase") + next + end + + next if branch == 'trunk' + run_command("git branch -t #{branch} remotes/#{branch}") run_command("git checkout #{branch}") - run_command("git checkout -b #{branch}") end end def fix_trunk trunk = @remote.find { |b| b.strip == 'trunk' } - if trunk + if trunk and not @options.fetch(:rebase, false) run_command("git checkout trunk") run_command("git branch -D master") run_command("git checkout -f -b master") - run_command("git branch -d -r trunk") + else + run_command("git checkout -f master") end end From 2bd075bd48b906650ed188235ac17b4fab44a5a8 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 29 May 2010 09:32:31 -0400 Subject: [PATCH 087/204] Updated Nathaniel's patch to match existing code style. --- lib/svn2git/migration.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 7d5129c..a803fee 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -10,17 +10,17 @@ class Migration def initialize(args) @options = parse(args) - if @options.fetch(:rebase, false) + if @options[:rebase] show_help_message('Too many arguments') if args.size > 0 else - show_help_message("Missing SVN_URL parameter") if args.empty? + show_help_message('Missing SVN_URL parameter') if args.empty? show_help_message('Too many arguments') if args.size > 1 @url = args.first end end def run! - if @options.fetch(:rebase, false) + if @options[:rebase] get_branches else clone! @@ -53,7 +53,7 @@ def parse(args) opts.separator '' opts.separator 'Specific options:' - opts.on('--rebase', 'Instead of cloning a new project, rebase an existing one against svn') do + opts.on('--rebase', 'Instead of cloning a new project, rebase an existing one against SVN') do options[:rebase] = true end @@ -189,7 +189,7 @@ def fix_branches svn_branches.each do |branch| branch = branch.strip - if @options.fetch(:rebase, false) and (@local.index(branch) != nil or branch == 'trunk') + if @options[:rebase] && (@local.include?(branch) || branch == 'trunk') branch = 'master' if branch == 'trunk' run_command("git checkout -f #{branch}") run_command("git svn rebase") @@ -204,7 +204,7 @@ def fix_branches def fix_trunk trunk = @remote.find { |b| b.strip == 'trunk' } - if trunk and not @options.fetch(:rebase, false) + if trunk && ! @options[:rebase] run_command("git checkout trunk") run_command("git branch -D master") run_command("git checkout -f -b master") From 29ea726d3f0fbe3a4edea268425537b7a9276ca3 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 29 May 2010 09:43:22 -0400 Subject: [PATCH 088/204] Updated changelog for 2.0.0 release. --- ChangeLog.markdown | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 0c6f26b..4e23772 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,16 @@ +# 2.0.0 - 2010-05-29 + + This release adds the oft requested incremental SVN update support. If you run svn2git with the `--rebase` option on an existing + repository that you've converted with svn2git, it will fetch new branches & tags from SVN and update existing ones. There are + two important things to note: + + * This will not work on already converted repositories because the tracking information isn't set up correctly. You could do that + yourself, but it's probably a lot easier to do the conversion over. + * svn2git now maintains remote tracking information. If this is a problem for you because you don't want any links to the SVN server + you can either stick with a 1.x release of svn2git or simply clone the repo created with svn2git, which will lose the tracking information. + + A great deal of thanks to Nathaniel McCallum (npmccallum) for coming up with an elegant solution and then providing the patch for this release. + # 1.3.3 - 2010-03-31 Thanks to Jeff Ramnani (jramnani) for finding a problem with with the --excludes tag and providing a patch. From 09e6d3a8dd16cf519d54241841d6733bc3cd4bf1 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 29 May 2010 09:58:19 -0400 Subject: [PATCH 089/204] Updated README with --rebase option docs. --- README.markdown | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 2b3b1dd..c4bffa9 100644 --- a/README.markdown +++ b/README.markdown @@ -74,7 +74,9 @@ Make sure you have git, ruby and rubygems installed, then install the gem: Usage ----- -There are a number of ways in which you can create a git repo from an existing +### Initial Conversion ### + +There are several ways you can create a git repo from an existing svn repo. The differentiating factor is the svn repo layout. Below is an enumerated listing of the varying supported layouts and the proper way to create a git repo from a svn repo in the specified layout. @@ -114,6 +116,16 @@ specified trunk=foo branches=bar and tags=foobar it would be referencing http://svn.example.com/path/to/repo/foo as your trunk, and so on. However, in case 4 it references the root of the repo as trunk. +### Repository Updates ### + +As of svn2git 2.0 there is a new feature to pull in the latest changes from SVN into your +git repository created with svn2git. This is a one way sync, but allows you to use svn2git +as a mirroring tool for your SVN repositories. + +The command to call is: + + $ cd && svn2git --rebase + Authors ------- From a43b0e78ce7bc21fc9b663c3c4e9e89cf61f7cb9 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 29 May 2010 14:47:05 -0400 Subject: [PATCH 090/204] Make sure the working tree is clean before doing a rebase. --- lib/svn2git/blah.rb | 4 ++++ lib/svn2git/migration.rb | 9 +++++++++ 2 files changed, 13 insertions(+) create mode 100644 lib/svn2git/blah.rb diff --git a/lib/svn2git/blah.rb b/lib/svn2git/blah.rb new file mode 100644 index 0000000..66d2f0c --- /dev/null +++ b/lib/svn2git/blah.rb @@ -0,0 +1,4 @@ +require 'migration' + +migration = Svn2Git::Migration.new(ARGV) +migration.run! \ No newline at end of file diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index a803fee..b61c630 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -12,6 +12,7 @@ def initialize(args) @options = parse(args) if @options[:rebase] 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 @@ -241,6 +242,14 @@ def show_help_message(msg) puts @opts.help exit end + + def verify_working_tree_is_clean + status = run_command('git status --porcelain --untracked-files=no') + unless status.strip == '' + puts 'You have local pending changes. The working tree must be clean in order to continue.' + exit + end + end def escape_quotes(str) str.gsub("'", "'\\\\''") From e3f566d8939542d990c352cb354ae8d6e9c44e15 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 29 May 2010 14:48:13 -0400 Subject: [PATCH 091/204] Version bump to 2.0.0 --- VERSION.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.yml b/VERSION.yml index f638155..e04eb1e 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- -:minor: 3 :build: -:patch: 3 -:major: 1 +:patch: 0 +:major: 2 +:minor: 0 From 26ba5ff66b66f357c43e5b2718717b81883a3679 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 29 May 2010 14:48:25 -0400 Subject: [PATCH 092/204] Regenerated gemspec for version 2.0.0 --- svn2git.gemspec | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index c1b8fa6..bb41127 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "1.3.3" + s.version = "2.0.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2010-03-31} + s.date = %q{2010-05-29} s.default_executable = %q{svn2git} s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] @@ -26,20 +26,21 @@ Gem::Specification.new do |s| "VERSION.yml", "bin/svn2git", "lib/svn2git.rb", + "lib/svn2git/blah.rb", "lib/svn2git/migration.rb", "svn2git.gemspec" ] s.homepage = %q{https://www.negativetwenty.net/redmine/projects/svn2git} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.6} + s.rubygems_version = %q{1.3.7} s.summary = %q{A tool for migrating svn projects to git} if s.respond_to? :specification_version then current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION s.specification_version = 3 - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then else end else From 7f2f2104f04736369c366c6a5ae56ed5226e1e50 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 31 Aug 2010 05:28:40 +0800 Subject: [PATCH 093/204] Allow digits in subversion username when generating authors list from svn log. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index c4bffa9..431e537 100644 --- a/README.markdown +++ b/README.markdown @@ -153,7 +153,7 @@ repository which name on its own line. This would allow you to easily redirect the output of this command sequence to ~/.svn2git/authors and have a very good starting point for your mapping. - $ svn log | grep -E "r[0-9]+ \| [a-z]+ \|" | awk '{print $3}' | sort | uniq + $ svn log | grep -E "r[0-9]+ \| [a-z0-9]+ \|" | awk '{print $3}' | sort | uniq Debugging --------- From fe626d8c193b137ac841866f8864040bba425c91 Mon Sep 17 00:00:00 2001 From: pdf Date: Tue, 3 Aug 2010 20:22:04 +0800 Subject: [PATCH 094/204] Add option to allow metadata (git-svn-id) in git logs --- lib/svn2git/migration.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index b61c630..fc294ef 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -36,6 +36,7 @@ def parse(args) # Set up reasonable defaults for options. options = {} options[:verbose] = false + options[:metadata] = false options[:rootistrunk] = false options[:trunk] = 'trunk' options[:branches] = 'branches' @@ -88,6 +89,10 @@ def parse(args) options[:tags] = nil end + opts.on('-m', '--metadata', 'Include metadata in git logs (git-svn-id)') do + options[:metadata] = true + end + opts.on('--authors AUTHORS_FILE', "Path to file containing svn-to-git authors mapping (default: #{DEFAULT_AUTHORS_FILE})") do |authors| options[:authors] = authors end @@ -120,18 +125,23 @@ def clone! trunk = @options[:trunk] branches = @options[:branches] tags = @options[:tags] + metadata = @options[:metadata] rootistrunk = @options[:rootistrunk] authors = @options[:authors] exclude = @options[:exclude] if rootistrunk # Non-standard repository layout. The repository root is effectively 'trunk.' - run_command("git svn init --no-metadata --trunk=#{@url}") + cmd = "git svn init "--no-metadata --trunk=#{@url} + cmd += "--no-metadata " unless metadata + cmd += "--trunk=#{@url}" + run_command(cmd) else - cmd = "git svn init --no-metadata " + cmd = "git svn init " # Add each component to the command that was passed as an argument. + cmd += "--no-metadata " unless metadata cmd += "--trunk=#{trunk} " unless trunk.nil? cmd += "--tags=#{tags} " unless tags.nil? cmd += "--branches=#{branches} " unless branches.nil? From a02c141a6801d8bfa6a5583317085bd0a91e999c Mon Sep 17 00:00:00 2001 From: pdf Date: Thu, 2 Sep 2010 08:09:23 +0800 Subject: [PATCH 095/204] Fix for previous commit --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index fc294ef..5f17bb8 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -132,7 +132,7 @@ def clone! if rootistrunk # Non-standard repository layout. The repository root is effectively 'trunk.' - cmd = "git svn init "--no-metadata --trunk=#{@url} + cmd = "git svn init " cmd += "--no-metadata " unless metadata cmd += "--trunk=#{@url}" run_command(cmd) From 5cfebd889adcdb36809bef95801edf1d78cacfbc Mon Sep 17 00:00:00 2001 From: Tristan Rivoallan Date: Thu, 20 Jan 2011 17:38:39 +0100 Subject: [PATCH 096/204] Regex provided to jump start authors files does not get usernames with special chars. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 431e537..677a78f 100644 --- a/README.markdown +++ b/README.markdown @@ -153,7 +153,7 @@ repository which name on its own line. This would allow you to easily redirect the output of this command sequence to ~/.svn2git/authors and have a very good starting point for your mapping. - $ svn log | grep -E "r[0-9]+ \| [a-z0-9]+ \|" | awk '{print $3}' | sort | uniq + $ svn log | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | sort | uniq Debugging --------- From a59cb83ac74caca9407db20c67a66db50556ecd8 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Mon, 24 Jan 2011 21:43:17 -0500 Subject: [PATCH 097/204] Better exit status. --- lib/svn2git/migration.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index b61c630..c6a0b27 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -242,12 +242,12 @@ def show_help_message(msg) puts @opts.help exit end - + def verify_working_tree_is_clean status = run_command('git status --porcelain --untracked-files=no') unless status.strip == '' puts 'You have local pending changes. The working tree must be clean in order to continue.' - exit + exit -1 end end From 5a73de8f9bb5911962be580fc87308b598e53de9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Rey?= Date: Tue, 29 Mar 2011 18:14:35 +0200 Subject: [PATCH 098/204] Added --no-minimize-url option, same as git-svn option --- lib/svn2git/migration.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 8e4b19f..812ae8f 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -37,6 +37,7 @@ def parse(args) options = {} options[:verbose] = false options[:metadata] = false + options[:nominimizeurl] = false options[:rootistrunk] = false options[:trunk] = 'trunk' options[:branches] = 'branches' @@ -89,6 +90,10 @@ def parse(args) options[:tags] = nil end + opts.on('--no-minimize-url', 'Accept URLs as-is without attempting to connect to a higher level directory') do + options[:nominimizeurl] = true + end + opts.on('-m', '--metadata', 'Include metadata in git logs (git-svn-id)') do options[:metadata] = true end @@ -126,6 +131,7 @@ def clone! branches = @options[:branches] tags = @options[:tags] metadata = @options[:metadata] + nominimizeurl = @options[:nominimizeurl] rootistrunk = @options[:rootistrunk] authors = @options[:authors] exclude = @options[:exclude] @@ -134,6 +140,9 @@ def clone! # Non-standard repository layout. The repository root is effectively 'trunk.' cmd = "git svn init " cmd += "--no-metadata " unless metadata + if nominimizeurl + cmd += "--no-minimize-url " + end cmd += "--trunk=#{@url}" run_command(cmd) @@ -142,6 +151,9 @@ def clone! # Add each component to the command that was passed as an argument. cmd += "--no-metadata " unless metadata + if nominimizeurl + cmd += "--no-minimize-url " + end cmd += "--trunk=#{trunk} " unless trunk.nil? cmd += "--tags=#{tags} " unless tags.nil? cmd += "--branches=#{branches} " unless branches.nil? From 7430bc3467a2ceb7ff65943211d793cddbae4a9d Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 3 Apr 2011 11:14:11 -0400 Subject: [PATCH 099/204] Document new --no-minimize-url option. --- ChangeLog.markdown | 6 ++++++ README.markdown | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 4e23772..7fa947b 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,9 @@ +# 2.1.0 + + This release handles some corner cases with cloning git repositories, making svn2git applicable to wider environments. + + * Added --no-minimize-url option (thanks fmjrey) + # 2.0.0 - 2010-05-29 This release adds the oft requested incremental SVN update support. If you run svn2git with the `--rebase` option on an existing diff --git a/README.markdown b/README.markdown index 677a78f..c9977ca 100644 --- a/README.markdown +++ b/README.markdown @@ -107,6 +107,11 @@ doc directory and the backup files you once accidently added. $ svn2git http://svn.example.com/path/to/repo --exclude doc --exclude '.*~$' +6. The svn repo actually tracks several projects and you only want to migrate +one of them. + + $ svn2git http://svn.example.com/path/to/repo/nested_project --no-minimize-url + The above will create a git repository in the current directory with the git version of the svn repository. Hence, you need to make a directory that you want your new git repo to exist in, change into it and then run one of the From 80383ebca68bcbfd5efc31b1466f774c66e86445 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 3 Apr 2011 11:24:33 -0400 Subject: [PATCH 100/204] Added support for --username and --revision options (thanks svenax). --- ChangeLog.markdown | 4 +++- README.markdown | 8 +++++++ lib/svn2git/migration.rb | 52 ++++++++++++++++++++++++++++------------ 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 7fa947b..1282bff 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -2,7 +2,9 @@ This release handles some corner cases with cloning git repositories, making svn2git applicable to wider environments. - * Added --no-minimize-url option (thanks fmjrey) + * Added --no-minimize-url option for migrating specific subprojects from an SVN repo containing several projects (thanks fmjrey). + * Added --username option for migrating password-protected repositories (thanks svenax). + * Added --revision option for specifying the revision to start importing from (thanks svenax). # 2.0.0 - 2010-05-29 diff --git a/README.markdown b/README.markdown index c9977ca..880fd50 100644 --- a/README.markdown +++ b/README.markdown @@ -112,6 +112,14 @@ one of them. $ svn2git http://svn.example.com/path/to/repo/nested_project --no-minimize-url +7. The svn repo is password protected. + + $ svn2git http://svn.example.com/path/to/repo --username <> + +8. You need to migrate starting at a specific svn revision number. + + $ svn2git http://svn.example.com/path/to/repo --revision <> + The above will create a git repository in the current directory with the git version of the svn repository. Hence, you need to make a directory that you want your new git repo to exist in, change into it and then run one of the diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 812ae8f..1e25cac 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -43,6 +43,8 @@ def parse(args) options[:branches] = 'branches' options[:tags] = 'tags' options[:exclude] = [] + options[:revision] = nil + options[:username] = nil if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE)) options[:authors] = DEFAULT_AUTHORS_FILE @@ -60,6 +62,10 @@ def parse(args) options[:rebase] = true end + opts.on('--username NAME', 'Username for transports that needs it (http(s), svn)') do |username| + options[:username] = username + end + opts.on('--trunk TRUNK_PATH', 'Subpath to trunk from repository URL (default: trunk)') do |trunk| options[:trunk] = trunk end @@ -67,6 +73,7 @@ def parse(args) opts.on('--branches BRANCHES_PATH', 'Subpath to branches from repository URL (default: branches)') do |branches| options[:branches] = branches end + opts.on('--tags TAGS_PATH', 'Subpath to tags from repository URL (default: tags)') do |tags| options[:tags] = tags end @@ -94,6 +101,10 @@ def parse(args) options[:nominimizeurl] = true end + opts.on('--revision REV', 'Start importing from SVN revision') do |revision| + options[:revision] = revision + end + opts.on('-m', '--metadata', 'Include metadata in git logs (git-svn-id)') do options[:metadata] = true end @@ -135,10 +146,13 @@ def clone! rootistrunk = @options[:rootistrunk] authors = @options[:authors] exclude = @options[:exclude] + revision = @options[:revision] + username = @options[:username] if rootistrunk # Non-standard repository layout. The repository root is effectively 'trunk.' - cmd = "git svn init " + cmd = "git svn init --prefix=svn/ " + cmd += "--username=#{username} " unless username.nil? cmd += "--no-metadata " unless metadata if nominimizeurl cmd += "--no-minimize-url " @@ -147,9 +161,10 @@ def clone! run_command(cmd) else - cmd = "git svn init " + cmd = "git svn init --prefix=svn/ " # Add each component to the command that was passed as an argument. + cmd += "--username=#{username} " unless username.nil? cmd += "--no-metadata " unless metadata if nominimizeurl cmd += "--no-minimize-url " @@ -165,7 +180,8 @@ def clone! run_command("git config svn.authorsfile #{authors}") unless authors.nil? - cmd = "git svn fetch" + cmd = "git svn fetch " + cmd += "-r #{revision}:HEAD " unless revision.nil? unless exclude.empty? # Add exclude paths to the command line; some versions of git support # this for fetch only, later also for init. @@ -176,7 +192,7 @@ def clone! regex << "#{branches}[/][^/]+[/]" unless branches.nil? end regex = '^(?:' + regex.join('|') + ')(?:' + exclude.join('|') + ')' - cmd += " '--ignore-paths=#{regex}'" + cmd += "'--ignore-paths=#{regex}'" end run_command(cmd) @@ -190,13 +206,13 @@ def get_branches @remote = run_command("git branch -r --no-color").split(/\n/).collect{ |b| b.gsub(/\*/,'').strip } # Tags are remote branches that start with "tags/". - @tags = @remote.find_all { |b| b.strip =~ %r{^tags\/} } + @tags = @remote.find_all { |b| b.strip =~ %r{^svn\/tags\/} } end def fix_tags @tags.each do |tag| tag = tag.strip - id = tag.gsub(%r{^tags\/}, '').strip + id = tag.gsub(%r{^svn\/tags\/}, '').strip subject = run_command("git log -1 --pretty=format:'%s' #{tag}") date = run_command("git log -1 --pretty=format:'%ci' #{tag}") subject = escape_quotes(subject) @@ -209,18 +225,24 @@ def fix_tags def fix_branches svn_branches = @remote.find_all { |b| not @tags.include?(b) } - svn_branches.each do |branch| - branch = branch.strip + svn_branches = @remote.find_all { |b| b.strip =~ %r{^svn\/} } + if @options[:rebase] + run_command("git svn fetch") + end + + svn_branches.each do |branch| + branch = branch.gsub(/^svn\//,'').strip if @options[:rebase] && (@local.include?(branch) || branch == 'trunk') - branch = 'master' if branch == 'trunk' - run_command("git checkout -f #{branch}") - run_command("git svn rebase") + lbranch = branch + lbranch = 'master' if branch == 'trunk' + run_command("git checkout -f #{lbranch}") + run_command("git rebase remotes/svn/#{branch}") next end - next if branch == 'trunk' - run_command("git branch -t #{branch} remotes/#{branch}") + next if branch == 'trunk' || @local.include?(branch) + run_command("git branch -t #{branch} remotes/svn/#{branch}") run_command("git checkout #{branch}") end end @@ -228,7 +250,7 @@ def fix_branches def fix_trunk trunk = @remote.find { |b| b.strip == 'trunk' } if trunk && ! @options[:rebase] - run_command("git checkout trunk") + run_command("git checkout svn/trunk") run_command("git branch -D master") run_command("git checkout -f -b master") else @@ -251,7 +273,7 @@ def run_command(cmd) ret << line end end - + ret end From e8d7c45735854044798389fc7a71c3bea83bc427 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Fri, 4 Mar 2011 10:50:10 +0100 Subject: [PATCH 101/204] replace git branch -t with git branch --track git <= 1.5.5.6 (and possibly more) does only have a --track and no -t flag. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 1e25cac..4e3a647 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -242,7 +242,7 @@ def fix_branches end next if branch == 'trunk' || @local.include?(branch) - run_command("git branch -t #{branch} remotes/svn/#{branch}") + run_command("git branch --track #{branch} remotes/svn/#{branch}") run_command("git checkout #{branch}") end end From 2b618889e53e77672817c553d37ba0bdefef37fb Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 3 Apr 2011 14:42:31 -0400 Subject: [PATCH 102/204] Updated changelog. --- ChangeLog.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 1282bff..17d0e71 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -5,6 +5,7 @@ * Added --no-minimize-url option for migrating specific subprojects from an SVN repo containing several projects (thanks fmjrey). * Added --username option for migrating password-protected repositories (thanks svenax). * Added --revision option for specifying the revision to start importing from (thanks svenax). + * Fixed compatibility with older versions of git (thanks juliantaylor). # 2.0.0 - 2010-05-29 From 319d1b11696cbf911f2de16a37e6b6015c844306 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 3 Apr 2011 15:03:41 -0400 Subject: [PATCH 103/204] Prepping the 2.1.0 release. --- ChangeLog.markdown | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 17d0e71..456a867 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,6 +1,7 @@ -# 2.1.0 +# 2.1.0 - 2011-04-03 - This release handles some corner cases with cloning git repositories, making svn2git applicable to wider environments. + Thanks to Francois Rey (fmjrey), Sven Axelsson (svenax), and Julian Taylor (juliantaylor) for submitting all the patches + that comprise this release. svn2git now works with a much wider array SVN repositories because of their efforts. * Added --no-minimize-url option for migrating specific subprojects from an SVN repo containing several projects (thanks fmjrey). * Added --username option for migrating password-protected repositories (thanks svenax). From b58ddd097b0f899e2f75d40c3b8075b958e5a682 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 3 Apr 2011 15:04:11 -0400 Subject: [PATCH 104/204] Version bump to 2.1.0 --- VERSION.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION.yml b/VERSION.yml index e04eb1e..e553d25 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- -:build: :patch: 0 +:build: :major: 2 -:minor: 0 +:minor: 1 From 0fca5c1cad2d21e153835cfb61154c26a65775ed Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 3 Apr 2011 15:04:37 -0400 Subject: [PATCH 105/204] Regenerate gemspec for version 2.1.0 --- svn2git.gemspec | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index bb41127..8676532 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -1,43 +1,40 @@ # Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY -# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command +# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "2.0.0" + s.version = "2.1.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2010-05-29} + s.date = %q{2011-04-03} s.default_executable = %q{svn2git} s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] s.extra_rdoc_files = [ "ChangeLog.markdown", - "README.markdown" + "README.markdown" ] s.files = [ - ".gitignore", - "ChangeLog.markdown", - "MIT-LICENSE", - "README.markdown", - "Rakefile", - "VERSION.yml", - "bin/svn2git", - "lib/svn2git.rb", - "lib/svn2git/blah.rb", - "lib/svn2git/migration.rb", - "svn2git.gemspec" + "ChangeLog.markdown", + "MIT-LICENSE", + "README.markdown", + "Rakefile", + "VERSION.yml", + "bin/svn2git", + "lib/svn2git.rb", + "lib/svn2git/blah.rb", + "lib/svn2git/migration.rb", + "svn2git.gemspec" ] s.homepage = %q{https://www.negativetwenty.net/redmine/projects/svn2git} - s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] - s.rubygems_version = %q{1.3.7} + s.rubygems_version = %q{1.5.3} s.summary = %q{A tool for migrating svn projects to git} if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then From 5cda5d615d09acb8dcca1d8921292cb342e9322f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Mej=C3=ADa?= Date: Thu, 15 Sep 2011 12:36:33 -0500 Subject: [PATCH 106/204] Grammar police is here! --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 880fd50..efa14fc 100644 --- a/README.markdown +++ b/README.markdown @@ -204,7 +204,7 @@ FAQ If we were to reference the parent of this svn tagged commit there could potentially be situations where a developer would checkout a tag in git - and the resulting code base would be different then if they checked out + and the resulting code base would be different than if they checked out 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. From cf91bb87dc7fe9312caf046ece153e5b51113925 Mon Sep 17 00:00:00 2001 From: Simon Chiang Date: Wed, 7 Sep 2011 14:29:23 -0600 Subject: [PATCH 107/204] correct svn branch detection The previous code didn't actually remove the tags from the list of svn_branches. As a result you could get failures for a non-existant branch (because it was just deleted in the fix_tags code). --- lib/svn2git/migration.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 4e3a647..1e138e9 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -224,8 +224,8 @@ def fix_tags end def fix_branches - svn_branches = @remote.find_all { |b| not @tags.include?(b) } - svn_branches = @remote.find_all { |b| b.strip =~ %r{^svn\/} } + svn_branches = @remote - @tags + svn_branches.delete_if { |b| b.strip !~ %r{^svn\/} } if @options[:rebase] run_command("git svn fetch") From f63db4930d1a18d43838ecf90132817cf8ccdc7d Mon Sep 17 00:00:00 2001 From: Simon Chiang Date: Mon, 12 Sep 2011 13:28:34 -0600 Subject: [PATCH 108/204] make conversion exit on cmd error --- lib/svn2git/migration.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 4e3a647..451bd74 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -267,6 +267,7 @@ def run_command(cmd) ret = '' + cmd = "2>&1 #{cmd}" IO.popen(cmd) do |stdout| stdout.each do |line| log line @@ -274,6 +275,11 @@ def run_command(cmd) end end + unless $?.exitstatus == 0 + $stderr.puts "command failed:\n#{cmd}" + exit 1 + end + ret end From 17a9478671786cf849be4b4a85c1b2625551d4a1 Mon Sep 17 00:00:00 2001 From: Simon Chiang Date: Wed, 7 Sep 2011 14:49:02 -0600 Subject: [PATCH 109/204] ensure svn author file is a local config --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 4e3a647..c13ca4f 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -178,7 +178,7 @@ def clone! run_command(cmd) end - run_command("git config svn.authorsfile #{authors}") unless authors.nil? + run_command("git config --local svn.authorsfile #{authors}") unless authors.nil? cmd = "git svn fetch " cmd += "-r #{revision}:HEAD " unless revision.nil? From fa6492b339bde797ee60c796872378ae22e24cf0 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 27 Dec 2011 12:20:46 -0500 Subject: [PATCH 110/204] Started changelog entries for 2.1.1. --- ChangeLog.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 456a867..2a9a986 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,7 @@ +# 2.1.1 - Unreleased + + * Fixed SVN branch detection (thanks thinkerbot) + # 2.1.0 - 2011-04-03 Thanks to Francois Rey (fmjrey), Sven Axelsson (svenax), and Julian Taylor (juliantaylor) for submitting all the patches From 8f138ec9dd2a6206745acfab06c22655f1459181 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 27 Dec 2011 12:23:26 -0500 Subject: [PATCH 111/204] Use -1 exit code for consistency. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index d9cd09c..e2bdb84 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -277,7 +277,7 @@ def run_command(cmd) unless $?.exitstatus == 0 $stderr.puts "command failed:\n#{cmd}" - exit 1 + exit -1 end ret From 7418919652a4c81c2cca12abc614884d8c5151a9 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 27 Dec 2011 12:24:32 -0500 Subject: [PATCH 112/204] Note another fix in 2.1.1. --- ChangeLog.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 2a9a986..d89a8c2 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,6 +1,7 @@ -# 2.1.1 - Unreleased +# 2.1.1 - 2011-12-27 * Fixed SVN branch detection (thanks thinkerbot) + * Stop processing when a git subprocess fails (thanks thinkerbot) # 2.1.0 - 2011-04-03 From b3f0f10de8ec62920ed5b2d7b10e59527c933300 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 27 Dec 2011 12:35:58 -0500 Subject: [PATCH 113/204] Fixed issue #18: svn2git fails if branch contains shell special characters --- ChangeLog.markdown | 1 + lib/svn2git/migration.rb | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index d89a8c2..8da0650 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -2,6 +2,7 @@ * Fixed SVN branch detection (thanks thinkerbot) * Stop processing when a git subprocess fails (thanks thinkerbot) + * Fixed an issue with SVN branches containing shell special characters (thanks sleicht) # 2.1.0 - 2011-04-03 diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index e2bdb84..328a5c9 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -236,14 +236,14 @@ def fix_branches if @options[:rebase] && (@local.include?(branch) || branch == 'trunk') lbranch = branch lbranch = 'master' if branch == 'trunk' - run_command("git checkout -f #{lbranch}") - run_command("git rebase remotes/svn/#{branch}") + run_command("git checkout -f \"#{lbranch}\"") + run_command("git rebase \"remotes/svn/#{branch}\"") next end next if branch == 'trunk' || @local.include?(branch) - run_command("git branch --track #{branch} remotes/svn/#{branch}") - run_command("git checkout #{branch}") + run_command("git branch --track \"#{branch}\" \"remotes/svn/#{branch}\"") + run_command("git checkout \"#{branch}"\") end end From e3dca3c0f718ef35f215af72a4ba3c80bdbef354 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 27 Dec 2011 12:47:47 -0500 Subject: [PATCH 114/204] Fixed #16: Better installation instructions --- README.markdown | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index efa14fc..e59a86a 100644 --- a/README.markdown +++ b/README.markdown @@ -64,12 +64,16 @@ the svn repo. Installation ------------ -Make sure you have git, ruby and rubygems installed, then install the gem: +Make sure you have git, git-svn, and ruby installed. svn2git is a ruby wrapper around git's native SVN support through git-svn. It is possible to have git +installed without git-svn installed, so please do verify that you can run "$ git svn" successfully. For a Debian-based system, the installation of the +prerequisites would like like: $ sudo apt-get install git-core git-svn ruby rubygems - $ sudo gem install svn2git --source http://gemcutter.org - -*NB: Previous versions of the gem could be installed from GitHub as nirvdrum-svn2git. You can install that gem via `$ sudo gem install nirvdrum-svn2git --source http://gems.github.com`, but the nirvdrum-svn2git gem will no longer be updated. Please use the one hosted on gemcutter.* + +Once you have the necessary software your system, you can install svn2git through rubygems, which will add the `svn2git` command to your PATH. + + $ sudo gem install svn2git + Usage ----- From 29ec77276b04ccfd9e588d19fce7ab05066a7363 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 27 Dec 2011 12:48:35 -0500 Subject: [PATCH 115/204] Better doc formatting. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index e59a86a..7de82c9 100644 --- a/README.markdown +++ b/README.markdown @@ -65,7 +65,7 @@ Installation ------------ Make sure you have git, git-svn, and ruby installed. svn2git is a ruby wrapper around git's native SVN support through git-svn. It is possible to have git -installed without git-svn installed, so please do verify that you can run "$ git svn" successfully. For a Debian-based system, the installation of the +installed without git-svn installed, so please do verify that you can run `$ git svn` successfully. For a Debian-based system, the installation of the prerequisites would like like: $ sudo apt-get install git-core git-svn ruby rubygems From f434151efea09b886502ec1b76284ebf975e3952 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 27 Dec 2011 12:50:23 -0500 Subject: [PATCH 116/204] Version bump to 2.1.1 --- VERSION.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.yml b/VERSION.yml index e553d25..5d2049e 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ ---- -:patch: 0 -:build: +--- :major: 2 :minor: 1 +:patch: 1 +:build: !!null From 5d0309904033e70807031729b0c3b698d5994795 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 27 Dec 2011 12:50:38 -0500 Subject: [PATCH 117/204] Regenerate gemspec for version 2.1.1 --- svn2git.gemspec | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 8676532..b6fa8c3 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -4,14 +4,13 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = %q{svn2git} - s.version = "2.1.0" + s.name = "svn2git" + s.version = "2.1.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2011-04-03} - s.default_executable = %q{svn2git} - s.email = %q{nirvdrum@gmail.com} + s.date = "2011-12-27" + s.email = "nirvdrum@gmail.com" s.executables = ["svn2git"] s.extra_rdoc_files = [ "ChangeLog.markdown", @@ -29,10 +28,10 @@ Gem::Specification.new do |s| "lib/svn2git/migration.rb", "svn2git.gemspec" ] - s.homepage = %q{https://www.negativetwenty.net/redmine/projects/svn2git} + s.homepage = "https://www.negativetwenty.net/redmine/projects/svn2git" s.require_paths = ["lib"] - s.rubygems_version = %q{1.5.3} - s.summary = %q{A tool for migrating svn projects to git} + s.rubygems_version = "1.8.13" + s.summary = "A tool for migrating svn projects to git" if s.respond_to? :specification_version then s.specification_version = 3 From 5cac1e8879d4402c8e2f5234e095574fa1a8122e Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 28 Dec 2011 17:12:53 -0500 Subject: [PATCH 118/204] Fixed #38: Flaw in quoting of branch names. --- ChangeLog.markdown | 4 ++++ lib/svn2git/migration.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 8da0650..2409384 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,7 @@ +# 2.1.2 - 2011-12-28 + + * Fixed a regression in improperly quoting branch names (thanks ziangsong) + # 2.1.1 - 2011-12-27 * Fixed SVN branch detection (thanks thinkerbot) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 328a5c9..8516e9c 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -243,7 +243,7 @@ def fix_branches next if branch == 'trunk' || @local.include?(branch) run_command("git branch --track \"#{branch}\" \"remotes/svn/#{branch}\"") - run_command("git checkout \"#{branch}"\") + run_command("git checkout \"#{branch}\"") end end From 28f1739bae16a43002c0f77150aff1f402640671 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 28 Dec 2011 17:13:01 -0500 Subject: [PATCH 119/204] Version bump to 2.1.2 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 5d2049e..d04ebe5 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- :major: 2 :minor: 1 -:patch: 1 +:patch: 2 :build: !!null From fbb8fff7b3a96095786cf2a754ff1a5e7c3754d7 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 28 Dec 2011 17:13:10 -0500 Subject: [PATCH 120/204] Regenerate gemspec for version 2.1.2 --- svn2git.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index b6fa8c3..0181d45 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = "svn2git" - s.version = "2.1.1" + s.version = "2.1.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = "2011-12-27" + s.date = "2011-12-28" s.email = "nirvdrum@gmail.com" s.executables = ["svn2git"] s.extra_rdoc_files = [ From 04d2061c509136b027715760a52b5bcc62b72963 Mon Sep 17 00:00:00 2001 From: Craig Hobbs Date: Thu, 12 Jan 2012 10:43:46 -0800 Subject: [PATCH 121/204] Quote tags in git commands when fixing tags. This is important for tags with '(' and ')' characters. --- lib/svn2git/migration.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 8516e9c..662ee77 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -213,13 +213,13 @@ def fix_tags @tags.each do |tag| tag = tag.strip id = tag.gsub(%r{^svn\/tags\/}, '').strip - subject = run_command("git log -1 --pretty=format:'%s' #{tag}") - date = run_command("git log -1 --pretty=format:'%ci' #{tag}") + subject = run_command("git log -1 --pretty=format:'%s' '#{tag}'") + date = run_command("git log -1 --pretty=format:'%ci' '#{tag}'") subject = escape_quotes(subject) date = escape_quotes(date) id = escape_quotes(id) run_command("GIT_COMMITTER_DATE='#{date}' git tag -a -m '#{subject}' '#{id}' '#{escape_quotes(tag)}'") - run_command("git branch -d -r #{tag}") + run_command("git branch -d -r '#{tag}'") end end From 91dc3d02617c536eccdef6f5eebf1fd59fa24cfa Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 25 Jan 2012 10:23:40 -0500 Subject: [PATCH 122/204] Merge pull request #28 from thinkerbot/fix_tag_committer Fix tag committer. --- lib/svn2git/migration.rb | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 662ee77..ede1049 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -210,16 +210,32 @@ def get_branches end 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") + @tags.each do |tag| tag = tag.strip - id = tag.gsub(%r{^svn\/tags\/}, '').strip - subject = run_command("git log -1 --pretty=format:'%s' '#{tag}'") - date = run_command("git log -1 --pretty=format:'%ci' '#{tag}'") - subject = escape_quotes(subject) - date = escape_quotes(date) - id = escape_quotes(id) - run_command("GIT_COMMITTER_DATE='#{date}' git tag -a -m '#{subject}' '#{id}' '#{escape_quotes(tag)}'") - run_command("git branch -d -r '#{tag}'") + 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)}'") + 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}") + end end end From 6708b21382c274e7e6548046d142223469fcff60 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 25 Jan 2012 10:31:41 -0500 Subject: [PATCH 123/204] Preparing the 2.2.0 release. --- ChangeLog.markdown | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 2409384..226c254 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,12 @@ +# 2.2.0 - 2012-01-25 + + Thanks to Craig Hobbs (craigahobbs) and Simon Chiang (thinkerbot) for the patches making up this release. + It rounds out our tag support by handling tags with special characters and preserving original tag author info. + + * Fixed an issue with not quoting tag names (thanks craigahobbs and thinkerbot) + * Fixed an issue whereby the person running the svn2git conversion became the author of every tag (i.e., we lost the + original tag committer info) (thanks thinkerbot) + # 2.1.2 - 2011-12-28 * Fixed a regression in improperly quoting branch names (thanks ziangsong) From 954c06c371ca0c09162409bad834444208431e8c Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 25 Jan 2012 10:35:39 -0500 Subject: [PATCH 124/204] Version bump to 2.2.0 --- VERSION.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION.yml b/VERSION.yml index d04ebe5..fb4b3d1 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- :major: 2 -:minor: 1 -:patch: 2 -:build: !!null +:minor: 2 +:patch: 0 +:build: From db0769835e9d1d3ff324091a3bb7756200a09932 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 25 Jan 2012 10:35:47 -0500 Subject: [PATCH 125/204] Regenerate gemspec for version 2.2.0 --- svn2git.gemspec | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 0181d45..842f4f8 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = "svn2git" - s.version = "2.1.2" + s.version = "2.2.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = "2011-12-28" + s.date = "2012-01-25" s.email = "nirvdrum@gmail.com" s.executables = ["svn2git"] s.extra_rdoc_files = [ @@ -30,7 +30,7 @@ Gem::Specification.new do |s| ] s.homepage = "https://www.negativetwenty.net/redmine/projects/svn2git" s.require_paths = ["lib"] - s.rubygems_version = "1.8.13" + s.rubygems_version = "1.8.15" s.summary = "A tool for migrating svn projects to git" if s.respond_to? :specification_version then From 151905725449b91f0ca0bea0c114a6a81cfd5f75 Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Mon, 30 Jan 2012 15:46:46 +0100 Subject: [PATCH 126/204] allow specifying of end revision in --revision option --- lib/svn2git/migration.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index ede1049..7bae53e 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -101,7 +101,7 @@ def parse(args) options[:nominimizeurl] = true end - opts.on('--revision REV', 'Start importing from SVN revision') do |revision| + opts.on('--revision SREV[:EREV]', 'Start importing from SVN revision SREV; optionally end at EREV') do |revision| options[:revision] = revision end @@ -181,7 +181,9 @@ def clone! run_command("git config --local svn.authorsfile #{authors}") unless authors.nil? cmd = "git svn fetch " - cmd += "-r #{revision}:HEAD " unless revision.nil? + range = revision.split(":") unless revision.nil? + range[1] = "HEAD" unless range[1] + cmd += "-r #{range[0]}:#{range[1]} " unless revision.nil? unless exclude.empty? # Add exclude paths to the command line; some versions of git support # this for fetch only, later also for init. From 8fbacbd084da08bd860cb2327d378684cc1a5e27 Mon Sep 17 00:00:00 2001 From: David Zuelke Date: Tue, 31 Jan 2012 14:50:38 +0100 Subject: [PATCH 127/204] fix an issue when no revision was given at all --- lib/svn2git/migration.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 7bae53e..d42df7f 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -181,9 +181,11 @@ def clone! run_command("git config --local svn.authorsfile #{authors}") unless authors.nil? cmd = "git svn fetch " - range = revision.split(":") unless revision.nil? - range[1] = "HEAD" unless range[1] - cmd += "-r #{range[0]}:#{range[1]} " unless revision.nil? + unless revision.nil? + range = revision.split(":") + range[1] = "HEAD" unless range[1] + cmd += "-r #{range[0]}:#{range[1]} " + end unless exclude.empty? # Add exclude paths to the command line; some versions of git support # this for fetch only, later also for init. From c7a601c31722aed60ed1c23ced1490d07b7d3262 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Thu, 23 Feb 2012 08:03:38 -0500 Subject: [PATCH 128/204] Updated docs for SVN end revision work. --- ChangeLog.markdown | 12 ++++++++---- README.markdown | 4 ++++ lib/svn2git/migration.rb | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 226c254..b513b14 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,7 @@ +# 2.2.1 + + * Added the ability to specify an end revision for migration (thanks dzuelke). + # 2.2.0 - 2012-01-25 Thanks to Craig Hobbs (craigahobbs) and Simon Chiang (thinkerbot) for the patches making up this release. @@ -9,13 +13,13 @@ # 2.1.2 - 2011-12-28 - * Fixed a regression in improperly quoting branch names (thanks ziangsong) + * Fixed a regression in improperly quoting branch names (thanks ziangsong). # 2.1.1 - 2011-12-27 - * Fixed SVN branch detection (thanks thinkerbot) - * Stop processing when a git subprocess fails (thanks thinkerbot) - * Fixed an issue with SVN branches containing shell special characters (thanks sleicht) + * Fixed SVN branch detection (thanks thinkerbot). + * Stop processing when a git subprocess fails (thanks thinkerbot). + * Fixed an issue with SVN branches containing shell special characters (thanks sleicht). # 2.1.0 - 2011-04-03 diff --git a/README.markdown b/README.markdown index 7de82c9..11f8bcf 100644 --- a/README.markdown +++ b/README.markdown @@ -124,6 +124,10 @@ one of them. $ svn2git http://svn.example.com/path/to/repo --revision <> +9. You need to migrate starting at a specific svn revision number, ending at a specific revision number. + + $ svn2git http://svn.example.com/path/to/repo --revision <>:<> + The above will create a git repository in the current directory with the git version of the svn repository. Hence, you need to make a directory that you want your new git repo to exist in, change into it and then run one of the diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index d42df7f..9850fa3 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -101,7 +101,7 @@ def parse(args) options[:nominimizeurl] = true end - opts.on('--revision SREV[:EREV]', 'Start importing from SVN revision SREV; optionally end at EREV') do |revision| + opts.on('--revision START_REV[:END_REV]', 'Start importing from SVN revision START_REV; optionally end at END_REV') do |revision| options[:revision] = revision end From 81ee6e5d1586b6954157da4a2ac23c71290dccab Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 25 Feb 2012 17:08:12 -0500 Subject: [PATCH 129/204] Fixed an issue with initial conversion if the repo had tags. --- ChangeLog.markdown | 3 +++ lib/svn2git/migration.rb | 25 ++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) 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 From 11f135bd4f684fbd8c024f36738f9527f1b6ec18 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 25 Feb 2012 17:08:25 -0500 Subject: [PATCH 130/204] Version bump to 2.2.1 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index fb4b3d1..6864943 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- :major: 2 :minor: 2 -:patch: 0 +:patch: 1 :build: From ffedaee3555f159adaf9ace9ea57a07046f914b0 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 25 Feb 2012 17:08:33 -0500 Subject: [PATCH 131/204] Regenerate gemspec for version 2.2.1 --- svn2git.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 842f4f8..8909a3e 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = "svn2git" - s.version = "2.2.0" + s.version = "2.2.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = "2012-01-25" + s.date = "2012-02-25" s.email = "nirvdrum@gmail.com" s.executables = ["svn2git"] s.extra_rdoc_files = [ From 4b9fee44575daff23083523655d4aa3b96874fb8 Mon Sep 17 00:00:00 2001 From: Philipp Riemer Date: Wed, 21 Mar 2012 10:18:34 +0100 Subject: [PATCH 132/204] minor markup changes in README.markdown --- README.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 11f8bcf..c5d40b6 100644 --- a/README.markdown +++ b/README.markdown @@ -156,11 +156,11 @@ system with the list of conversions to make, one per line, for example: jcoglan = James Coglan stnick = Santa Claus -Then pass an +authors+ option to +svn2git+ pointing to your file: +Then pass an _authors_ option to svn2git pointing to your file: $ svn2git http://svn.example.com/path/to/repo --authors ~/authors.txt -Alternatively, you can place the authors file into ~/.svn2git/authors and +Alternatively, you can place the authors file into `~/.svn2git/authors` and svn2git will load it out of there. This allows you to build up one authors file for all your projects and have it loaded for each repository that you migrate. @@ -171,7 +171,7 @@ the logs from the svn repository, pulls out all the names from the commits, sorts them, and then reduces the list to only unique names. So, in the end it outputs a list of usernames of the people that made commits to the svn repository which name on its own line. This would allow you to easily -redirect the output of this command sequence to ~/.svn2git/authors and have +redirect the output of this command sequence to `~/.svn2git/authors` and have a very good starting point for your mapping. $ svn log | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | sort | uniq @@ -183,7 +183,7 @@ If you're having problems with converting your repository and you're not sure wh try turning on verbose logging. This will print out more information from the underlying git-svn process. -You can turn on verbose logging with the '-v' or '--verbose' flags, like so: +You can turn on verbose logging with the `-v` or `--verbose` flags, like so: $ svn2git http://svn.yoursite.com/path/to/repo --verbose From e73f1a29b6c187569d62e921195f88082e02e50f Mon Sep 17 00:00:00 2001 From: PowerKiKi Date: Thu, 12 Apr 2012 15:49:58 +0900 Subject: [PATCH 133/204] Tags are not correctly updated with "svn2git --rebase" command. Tags need to be fixed only after branches when using "svn2git --rebase". Otherwise tags are not yet fetched when attempting to fix them, resulting in tags not appearing as they should in git repository (they would only appear after a second "svn2git --rebase"). --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index f187d7b..5dee6e3 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -26,8 +26,8 @@ def run! else clone! end - fix_tags fix_branches + fix_tags fix_trunk optimize_repos end From f6610ab5453e1bcd7457b45968a148c5843bcc41 Mon Sep 17 00:00:00 2001 From: Ben Wolfe Date: Mon, 18 Jun 2012 17:49:13 -0300 Subject: [PATCH 134/204] Updated authors command: Added -q option so that only the authors are shown in the output. Added url example so that users are pulled from entire history --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 11f8bcf..0875fbe 100644 --- a/README.markdown +++ b/README.markdown @@ -174,7 +174,7 @@ repository which name on its own line. This would allow you to easily redirect the output of this command sequence to ~/.svn2git/authors and have a very good starting point for your mapping. - $ svn log | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | sort | uniq + $ svn -q log http://path/to/root/of/project | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | sort | uniq Debugging --------- From 7d5a0e849553a075156bdd42efdfbed1ff0bac82 Mon Sep 17 00:00:00 2001 From: Rudger Date: Sat, 14 Jul 2012 02:35:45 +0300 Subject: [PATCH 135/204] Update lib/svn2git/migration.rb, strips leading hyphens from tag names E.G.: svn/tags/--tagname becomes tagname (in stead of --tagname) --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index f187d7b..38429ae 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -220,7 +220,7 @@ def fix_tags @tags.each do |tag| tag = tag.strip - id = tag.gsub(%r{^svn\/tags\/}, '').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)}'") From d746a1f660a7968e33ebde20c544bd1a298ea39b Mon Sep 17 00:00:00 2001 From: CyberTech Date: Fri, 24 Aug 2012 15:06:52 -0700 Subject: [PATCH 136/204] Use double quotes in log commands for fix_tag, as the single quotes cause ambiguous param error. --- lib/svn2git/migration.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index f187d7b..c49b43e 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -221,10 +221,10 @@ def fix_tags @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)}'") + 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)}'") From e79188391f65751ad7786d4863f48203b1715a31 Mon Sep 17 00:00:00 2001 From: CyberTech Date: Fri, 24 Aug 2012 16:09:19 -0700 Subject: [PATCH 137/204] Pass double quotes around params on command line, not single, as the tag command doesn't like it. Fix up single quote escaping to remove excessive single quotes Remove single quote enclosures from git log return values before passing them back in. Explicitly set/unset GIT_COMMITTER_DATE rather than pass as leading command for windows compatibility. --- lib/svn2git/migration.rb | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index c49b43e..33bd302 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -221,24 +221,27 @@ def fix_tags @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)}\"") + ENV['GIT_COMMITTER_DATE']="#{escape_quotes(date)}" + run_command("git tag -a -m \"#{escape_quotes(subject)}\" \"#{escape_quotes(id)}\" \"#{escape_quotes(tag)}\"") + ENV['GIT_COMMITTER_DATE']=nil + 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. + ENV['GIT_COMMITTER_DATE']=nil 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 @@ -325,7 +328,7 @@ def verify_working_tree_is_clean end def escape_quotes(str) - str.gsub("'", "'\\\\''") + str.gsub(/[']/, '\\\\\'') end end From 7365c8b74fb30390aee4e9d279d44f4239f5ee4f Mon Sep 17 00:00:00 2001 From: Edson de Lima Date: Mon, 3 Sep 2012 10:52:16 -0300 Subject: [PATCH 138/204] Fixes the problem with repositories with a white space in name. Yes, exists someone in the world who did that. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index f187d7b..d84cf92 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -16,7 +16,7 @@ def initialize(args) 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 From 3817f2adb1010ce19b1ad1bda8bc58f35f591361 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 7 Oct 2012 10:04:11 -0400 Subject: [PATCH 139/204] Note the release date of 2.2.1. --- ChangeLog.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index cab5fbc..680b469 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,4 +1,4 @@ -# 2.2.1 +# 2.2.1 - 2012-02-25 This is a critical bugfix release if your repository has tags. Thanks to David Zülke (dzuelke) for the patches making up this release. From 19af23aca33687c25858520a08093640f9bc1d5c Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 7 Oct 2012 10:09:44 -0400 Subject: [PATCH 140/204] Use consistent quoting. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index d84cf92..8e8b849 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -16,7 +16,7 @@ def initialize(args) else show_help_message('Missing SVN_URL parameter') if args.empty? show_help_message('Too many arguments') if args.size > 1 - @url = args.first.gsub(" ", "\\ ") + @url = args.first.gsub(' ', "\\ ") end end From a2e90d3137135574582d53b031ead7f0e070e94f Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 7 Oct 2012 10:43:05 -0400 Subject: [PATCH 141/204] Show how to fetch author list for both local and remote repositories. --- README.markdown | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 0875fbe..7fbfc58 100644 --- a/README.markdown +++ b/README.markdown @@ -174,7 +174,11 @@ repository which name on its own line. This would allow you to easily redirect the output of this command sequence to ~/.svn2git/authors and have a very good starting point for your mapping. - $ svn -q log http://path/to/root/of/project | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | sort | uniq + $ svn log --quiet | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | sort | uniq + +Or, for a remote URL: + + $ svn log --quiet http://path/to/root/of/project | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | sort | uniq Debugging --------- From 075c8390f603b285210700c930ed7dc3fc22e4e2 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 7 Oct 2012 10:43:15 -0400 Subject: [PATCH 142/204] Updated the changelog for the 2.2.2 release. --- ChangeLog.markdown | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 680b469..8cd58f1 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,16 @@ +# 2.2.2 + + This is an overdue bugfix release. No new features were added, but several long-standing bugs fixed by the community + have been merged. Many thanks to Edson de Lima (edsonlima), Rudger (Rud5G), Ben Wolfe (bwolfe), CyberTech, PowerKiKi, and Philipp Riemer (ruderphilipp) for the pull requests. + + * Fixed an issue working with repositories that contained a space in the name (thanks edsonlima). + * Fixed an issue working with tags that contain a hyphen (thanks Rud5G). + * Fixed an issue with fixing tags during a rebase (thanks PowerKiKi). + * Double-quote git-svn commands working with tags to avoid issues with special strings (thanks CyberTech). + * Improved the documentation example of fetching the author list for an SVN repository (thanks bwolfe). + * Set the git committer date for tags in a more cross-platform manner (thanks CyberTech). + * Improved documentation formatting (thanks ruderphilipp). + # 2.2.1 - 2012-02-25 This is a critical bugfix release if your repository has tags. Thanks to David Zülke (dzuelke) for the patches making up this release. From ecde05a89ef04b5e3fdfaf7a4442593d24606f04 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 7 Oct 2012 10:44:11 -0400 Subject: [PATCH 143/204] Regenerate gemspec for version 2.2.1 --- svn2git.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 8909a3e..1f032d8 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |s| s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = "2012-02-25" + s.date = "2012-10-07" s.email = "nirvdrum@gmail.com" s.executables = ["svn2git"] s.extra_rdoc_files = [ @@ -30,7 +30,7 @@ Gem::Specification.new do |s| ] s.homepage = "https://www.negativetwenty.net/redmine/projects/svn2git" s.require_paths = ["lib"] - s.rubygems_version = "1.8.15" + s.rubygems_version = "1.8.23" s.summary = "A tool for migrating svn projects to git" if s.respond_to? :specification_version then From 1dd317e1f8efd9bf19e508573f30f718c9333f4f Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 7 Oct 2012 10:44:28 -0400 Subject: [PATCH 144/204] Version bump to 2.2.2 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 6864943..590ca8a 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- :major: 2 :minor: 2 -:patch: 1 +:patch: 2 :build: From 025f13c6b3d353b333657b302776193ced0f1479 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 7 Oct 2012 10:44:35 -0400 Subject: [PATCH 145/204] Regenerate gemspec for version 2.2.2 --- svn2git.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 1f032d8..2b7ed29 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = "svn2git" - s.version = "2.2.1" + s.version = "2.2.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] From 6fb3aeffd127abe809da02fced1e22010dc820c4 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 7 Oct 2012 12:18:30 -0300 Subject: [PATCH 146/204] Added release date for the 2.2.2 release. --- ChangeLog.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 8cd58f1..19a40f9 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,4 +1,4 @@ -# 2.2.2 +# 2.2.2 - 2012-10-07 This is an overdue bugfix release. No new features were added, but several long-standing bugs fixed by the community have been merged. Many thanks to Edson de Lima (edsonlima), Rudger (Rud5G), Ben Wolfe (bwolfe), CyberTech, PowerKiKi, and Philipp Riemer (ruderphilipp) for the pull requests. From c8edceef3a0e11f79286a296776fbf465dfb033c Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 7 Oct 2012 11:32:58 -0400 Subject: [PATCH 147/204] There's no need for this to be in an ensure block. --- lib/svn2git/migration.rb | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 3acb557..30c078c 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -228,14 +228,11 @@ def fix_tags 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 - + 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)}\"") + ENV['GIT_COMMITTER_DATE'] = original_git_committer_date + run_command("git branch -d -r \"#{escape_quotes(tag)}\"") end From 67087e4261a9666dfd3c69dfcb8dd74e09a2177e Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 19 Dec 2012 22:04:16 +0000 Subject: [PATCH 148/204] Add all options reference to the documentation --- README.markdown | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.markdown b/README.markdown index 620a712..53176d2 100644 --- a/README.markdown +++ b/README.markdown @@ -191,6 +191,32 @@ You can turn on verbose logging with the `-v` or `--verbose` flags, like so: $ svn2git http://svn.yoursite.com/path/to/repo --verbose +Options Reference +----------------- + + $ svn2git --help + Usage: svn2git SVN_URL [options] + + Specific options: + --rebase Instead of cloning a new project, rebase an existing one against SVN + --username NAME Username for transports that needs it (http(s), svn) + --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) + --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 + --notags Do not try to import any tags + --no-minimize-url Accept URLs as-is without attempting to connect to a higher level directory + --revision START_REV[:END_REV] + Start importing from SVN revision START_REV; optionally end at END_REV + -m, --metadata Include metadata in git logs (git-svn-id) + --authors AUTHORS_FILE Path to file containing svn-to-git authors mapping (default: ~/.svn2git/authors) + --exclude REGEX Specify a Perl regular expression to filter paths when fetching; can be used multiple times + -v, --verbose Be verbose in logging -- useful for debugging issues + + -h, --help Show this message + FAQ --- @@ -220,3 +246,4 @@ 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. + From ae38e0f79a915eb569e7e70dff5cd524422e6ef8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 19 Dec 2012 22:20:18 +0000 Subject: [PATCH 149/204] Add metadata example --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 53176d2..92e8a31 100644 --- a/README.markdown +++ b/README.markdown @@ -128,6 +128,10 @@ one of them. $ svn2git http://svn.example.com/path/to/repo --revision <>:<> +10. Include metadata (git-svn-id) in git logs. + + $ svn2git http://svn.example.com/path/to/repo --metadata + The above will create a git repository in the current directory with the git version of the svn repository. Hence, you need to make a directory that you want your new git repo to exist in, change into it and then run one of the From 5ba5d8f94786cc085d96cfaf687944f5bc5937b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Teresa=20Teod=C3=B3sio?= Date: Wed, 20 Nov 2013 16:36:37 +0000 Subject: [PATCH 150/204] Explicitly require rubygems Not every Ruby installation is setup to load rubygems automatically, so it is a good idea to require it before requiring svn2git gem. --- bin/svn2git | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/svn2git b/bin/svn2git index 7609e6d..63bbf00 100644 --- a/bin/svn2git +++ b/bin/svn2git @@ -20,6 +20,7 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +require 'rubygems' require 'svn2git' migration = Svn2Git::Migration.new(ARGV) From 9a782962ba927c7f49087ce78fa29515e9d59e0a Mon Sep 17 00:00:00 2001 From: Jason McCreary Date: Wed, 1 Jan 2014 20:03:56 -0500 Subject: [PATCH 151/204] Fixed typos in README. --- README.markdown | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 92e8a31..424fa27 100644 --- a/README.markdown +++ b/README.markdown @@ -64,13 +64,11 @@ the svn repo. Installation ------------ -Make sure you have git, git-svn, and ruby installed. svn2git is a ruby wrapper around git's native SVN support through git-svn. It is possible to have git -installed without git-svn installed, so please do verify that you can run `$ git svn` successfully. For a Debian-based system, the installation of the -prerequisites would like like: +Make sure you have git, git-svn, and ruby installed. svn2git is a ruby wrapper around git's native SVN support through git-svn. It is possible to have git installed without git-svn installed, so please do verify that you can run `$ git svn` successfully. For a Debian-based system, the installation of the prerequisites would look like: $ sudo apt-get install git-core git-svn ruby rubygems -Once you have the necessary software your system, you can install svn2git through rubygems, which will add the `svn2git` command to your PATH. +Once you have the necessary software on your system, you can install svn2git through rubygems, which will add the `svn2git` command to your PATH. $ sudo gem install svn2git From b7a00257e08b9452ad240ec441914761c4562291 Mon Sep 17 00:00:00 2001 From: Stefan Sundin Date: Sun, 12 Jan 2014 20:25:51 -0800 Subject: [PATCH 152/204] Update README.markdown --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 424fa27..81f2257 100644 --- a/README.markdown +++ b/README.markdown @@ -176,11 +176,11 @@ repository which name on its own line. This would allow you to easily redirect the output of this command sequence to `~/.svn2git/authors` and have a very good starting point for your mapping. - $ svn log --quiet | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | sort | uniq + $ svn log --quiet | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/^ //' | sort | uniq Or, for a remote URL: - $ svn log --quiet http://path/to/root/of/project | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | sort | uniq + $ svn log --quiet http://path/to/root/of/project | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/^ //' | sort | uniq Debugging --------- From 44f7e9d906b008fdcd574cd8fa707888c23e0604 Mon Sep 17 00:00:00 2001 From: Gard Rimestad Date: Tue, 23 Apr 2013 09:13:10 +0200 Subject: [PATCH 153/204] Rebase a specified branch with --rebasebranch BRANCHNAME --- lib/svn2git/migration.rb | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 30c078c..2a723a3 100644 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -13,6 +13,9 @@ def initialize(args) if @options[:rebase] show_help_message('Too many arguments') if args.size > 0 verify_working_tree_is_clean + elsif @options[:rebasebranch] + 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 @@ -23,6 +26,8 @@ def initialize(args) def run! if @options[:rebase] get_branches + elsif @options[:rebasebranch] + get_rebasebranch else clone! end @@ -45,6 +50,7 @@ def parse(args) options[:exclude] = [] options[:revision] = nil options[:username] = nil + options[:rebasebranch] = false if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE)) options[:authors] = DEFAULT_AUTHORS_FILE @@ -121,6 +127,10 @@ def parse(args) options[:verbose] = true end + opts.on('--rebasebranch REBASEBRANCH', 'Rebase specified branch.') do |rebasebranch| + options[:rebasebranch] = rebasebranch + end + opts.separator "" # No argument, shows at tail. This will print an options summary. @@ -211,6 +221,34 @@ def get_branches # Tags are remote branches that start with "tags/". @tags = @remote.find_all { |b| b.strip =~ %r{^svn\/tags\/} } + + end + + def get_rebasebranch + get_branches + @local = @local.find_all{|l| l == @options[:rebasebranch]} + @remote = @remote.find_all{|r| r.include? @options[:rebasebranch]} + + if @local.count > 1 + pp "To many matching branches found (#{@local})." + exit 1 + elsif @local.count == 0 + pp "No local branch named \"#{@options[:rebasebranch]}\" found." + exit 1 + end + + if @remote.count > 2 # 1 if remote is not pushed, 2 if its pushed to remote + pp "To many matching remotes found (#{@remotes})" + exit 1 + elsif @remote.count == 0 + pp "No remote branch named \"#{@options[:rebasebranch]}\" found." + exit 1 + end + pp "Local branches \"#{@local}\" found" + pp "Remote branches \"#{@remote}\" found" + + @tags = [] # We only rebase the specified branch + end def fix_tags From 4dc1279d8b351547c3180aef4594454154f3baaf Mon Sep 17 00:00:00 2001 From: Gard Rimestad Date: Tue, 23 Apr 2013 09:15:26 +0200 Subject: [PATCH 154/204] rake/gempackagetask is deprecated, use rubygems/package_task --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 00d41e2..798f44e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,5 +1,5 @@ require 'rake' -require 'rake/gempackagetask' +require 'rubygems/package_task' begin require 'jeweler' From 3b90bafc39692bcbd19a633ee6111354d5a14868 Mon Sep 17 00:00:00 2001 From: Felix Jankowski Date: Mon, 6 May 2013 12:00:26 +0200 Subject: [PATCH 155/204] Fixes problems with untrusted certificate and password protected repositories --- ChangeLog.markdown | 7 +++++++ VERSION.yml | 2 +- lib/svn2git/migration.rb | 23 +++++++++++++++-------- svn2git.gemspec | 2 +- 4 files changed, 24 insertions(+), 10 deletions(-) mode change 100644 => 100755 lib/svn2git/migration.rb diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 19a40f9..c7edff8 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,10 @@ +# 2.2.3 + + This is a bugfix release. First change done by FeeJai + * Fixed an issue with password protected svn-repositories. The prompt to enter the password is now displayed. + * Fixed an issue with server certificates. If the certificate is untrusted, the prompt to confirm or deny the certificate is now shown + + # 2.2.2 - 2012-10-07 This is an overdue bugfix release. No new features were added, but several long-standing bugs fixed by the community diff --git a/VERSION.yml b/VERSION.yml index 590ca8a..5f918c0 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- :major: 2 :minor: 2 -:patch: 2 +:patch: 3 :build: diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb old mode 100644 new mode 100755 index 2a723a3..466fcb5 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -168,7 +168,7 @@ def clone! cmd += "--no-minimize-url " end cmd += "--trunk=#{@url}" - run_command(cmd) + run_command(cmd, true, true) else cmd = "git svn init --prefix=svn/ " @@ -185,7 +185,7 @@ def clone! cmd += @url - run_command(cmd) + run_command(cmd, true, true) end run_command("git config --local svn.authorsfile #{authors}") unless authors.nil? @@ -208,7 +208,7 @@ def clone! regex = '^(?:' + regex.join('|') + ')(?:' + exclude.join('|') + ')' cmd += "'--ignore-paths=#{regex}'" end - run_command(cmd) + run_command(cmd, true, true) get_branches end @@ -294,7 +294,7 @@ def fix_branches svn_branches.delete_if { |b| b.strip !~ %r{^svn\/} } if @options[:rebase] - run_command("git svn fetch") + run_command("git svn fetch", true, true) end svn_branches.each do |branch| @@ -328,16 +328,23 @@ def optimize_repos run_command("git gc") end - def run_command(cmd, exit_on_error=true) + def run_command(cmd, exit_on_error=true, printout_output=false) log "Running command: #{cmd}" ret = '' cmd = "2>&1 #{cmd}" IO.popen(cmd) do |stdout| - stdout.each do |line| - log line - ret << line + if printout_output + stdout.each_char do |character| + $stdout.print character + ret << character + end + else + stdout.each do |line| + log line + ret << line + end end end diff --git a/svn2git.gemspec b/svn2git.gemspec index 2b7ed29..42d2735 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -5,7 +5,7 @@ Gem::Specification.new do |s| s.name = "svn2git" - s.version = "2.2.2" + s.version = "2.2.3" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] From 85fe62782147586e55ce0397186330a18017e186 Mon Sep 17 00:00:00 2001 From: Ain Tohvri Date: Wed, 8 May 2013 16:58:22 +0300 Subject: [PATCH 156/204] Remove --local option from git-config call Remove --local option from git-config call to prevent a break on Debian Squeeze systems where --local is not yet available. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 466fcb5..885bbf6 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -188,7 +188,7 @@ def clone! run_command(cmd, true, true) end - run_command("git config --local svn.authorsfile #{authors}") unless authors.nil? + run_command("git config svn.authorsfile #{authors}") unless authors.nil? cmd = "git svn fetch " unless revision.nil? From 1eae52d499f0731168d7fd32cbf8a64f40ccdca5 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 8 Mar 2014 18:53:46 -0500 Subject: [PATCH 157/204] Fixed 'git config --local' to work on git versions < 1.7.4. --- lib/svn2git/migration.rb | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 885bbf6..d4fbbe2 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -188,7 +188,7 @@ def clone! run_command(cmd, true, true) end - run_command("git config svn.authorsfile #{authors}") unless authors.nil? + run_command("#{git_config_command} svn.authorsfile #{authors}") unless authors.nil? cmd = "git svn fetch " unless revision.nil? @@ -253,8 +253,8 @@ def get_rebasebranch def fix_tags current = {} - current['user.name'] = run_command("git config --local --get user.name", false) - current['user.email'] = run_command("git config --local --get user.email", false) + current['user.name'] = run_command("#{git_config_command} --get user.name", false) + current['user.email'] = run_command("#{git_config_command} --get user.email", false) @tags.each do |tag| tag = tag.strip @@ -263,8 +263,8 @@ 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 - run_command("git config --local user.name \"#{escape_quotes(author)}\"") - run_command("git config --local user.email \"#{escape_quotes(email)}\"") + 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) @@ -281,9 +281,9 @@ def fix_tags # 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_command} #{name} \"#{value.strip}\"") else - run_command("git config --local --unset #{name}") + run_command("#{git_config_command} --unset #{name}") end end end @@ -378,6 +378,20 @@ def escape_quotes(str) str.gsub("'", "'\\\\''") end + def git_config_command + if @git_config_command.nil? + status = run_command('git config --local --get user.name', false) + + @git_config_command = if status =~ /unknown option/m + 'git config' + else + 'git config --local' + end + end + + @git_config_command + end + end end From 7062de05e7cc6dd2ee5ac06b4d8a211b2508543b Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 8 Mar 2014 19:02:41 -0500 Subject: [PATCH 158/204] Preparing the 2.2.3 release. --- ChangeLog.markdown | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index c7edff8..ae73c90 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,8 +1,9 @@ -# 2.2.3 +# 2.2.3 - 2014-04-08 This is a bugfix release. First change done by FeeJai * Fixed an issue with password protected svn-repositories. The prompt to enter the password is now displayed. - * Fixed an issue with server certificates. If the certificate is untrusted, the prompt to confirm or deny the certificate is now shown + * Fixed an issue with server certificates. If the certificate is untrusted, the prompt to confirm or deny the certificate is now shown. + * Fixed an issue with using the `--local` flag for `git config` in git versions < 1.7.4. # 2.2.2 - 2012-10-07 From 8e96549c91558b1b829a7e99adbb44e08fac5bfb Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 8 Mar 2014 19:04:16 -0500 Subject: [PATCH 159/204] Regenerate gemspec for version 2.2.3 --- svn2git.gemspec | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 42d2735..98df049 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,14 +2,16 @@ # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- +# stub: svn2git 2.2.3 ruby lib Gem::Specification.new do |s| s.name = "svn2git" s.version = "2.2.3" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib"] s.authors = ["James Coglan", "Kevin Menard"] - s.date = "2012-10-07" + s.date = "2014-03-09" s.email = "nirvdrum@gmail.com" s.executables = ["svn2git"] s.extra_rdoc_files = [ @@ -29,17 +31,7 @@ Gem::Specification.new do |s| "svn2git.gemspec" ] s.homepage = "https://www.negativetwenty.net/redmine/projects/svn2git" - s.require_paths = ["lib"] - s.rubygems_version = "1.8.23" + s.rubygems_version = "2.2.0" s.summary = "A tool for migrating svn projects to git" - - if s.respond_to? :specification_version then - s.specification_version = 3 - - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - else - end - else - end end From 245b1f7b521bd28d707f83b8dae54255063e498c Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 8 Mar 2014 19:06:40 -0500 Subject: [PATCH 160/204] Version bump to 2.2.4 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 5f918c0..2dd9e2b 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- :major: 2 :minor: 2 -:patch: 3 +:patch: 4 :build: From a867b2784e53356ec64d0f7c48d23694014e1147 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 8 Mar 2014 19:06:54 -0500 Subject: [PATCH 161/204] Preparing the 2.2.4 release. --- ChangeLog.markdown | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index ae73c90..8e9cc83 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,6 +1,13 @@ +# 2.2.4 - 2014-04-08 + + There was a permissions problem with some of the files packed in 2.2.3. This was caught immediately after the gem + was pushed, so it was yanked as it simply wouldn't work for anyone. 2.2.4 contains everything 2.2.3 did, but with + proper packaging. + # 2.2.3 - 2014-04-08 This is a bugfix release. First change done by FeeJai + * Fixed an issue with password protected svn-repositories. The prompt to enter the password is now displayed. * Fixed an issue with server certificates. If the certificate is untrusted, the prompt to confirm or deny the certificate is now shown. * Fixed an issue with using the `--local` flag for `git config` in git versions < 1.7.4. From f4c18ba526ac07a551c871ebdd6cc37c807bb697 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sat, 8 Mar 2014 19:07:02 -0500 Subject: [PATCH 162/204] Regenerate gemspec for version 2.2.4 --- svn2git.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 98df049..209fe8d 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,11 +2,11 @@ # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- -# stub: svn2git 2.2.3 ruby lib +# stub: svn2git 2.2.4 ruby lib Gem::Specification.new do |s| s.name = "svn2git" - s.version = "2.2.3" + s.version = "2.2.4" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] From 8db94149ab78076510e62f586f7bc1689204323f Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 11:25:50 -0400 Subject: [PATCH 163/204] Removed a file I accidentally added about 4 years ago. --- lib/svn2git/blah.rb | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 lib/svn2git/blah.rb diff --git a/lib/svn2git/blah.rb b/lib/svn2git/blah.rb deleted file mode 100644 index 66d2f0c..0000000 --- a/lib/svn2git/blah.rb +++ /dev/null @@ -1,4 +0,0 @@ -require 'migration' - -migration = Svn2Git::Migration.new(ARGV) -migration.run! \ No newline at end of file From 994d1b8a30fbe0b888c90154bdedc8f981f53edb Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 19:34:52 -0400 Subject: [PATCH 164/204] Fixed 'jeweler' installation instructions. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 798f44e..b57f2e9 100644 --- a/Rakefile +++ b/Rakefile @@ -13,7 +13,7 @@ begin Jeweler::GemcutterTasks.new rescue LoadError - puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" + puts "Jeweler not available. Install it with: gem install jeweler" end # From 9b5b44a7fa14536ef704a8c838dafddbffabae8b Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 19:35:13 -0400 Subject: [PATCH 165/204] Updated gemspec to remove blah.rb. --- svn2git.gemspec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 209fe8d..6e205e9 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -26,12 +26,11 @@ Gem::Specification.new do |s| "VERSION.yml", "bin/svn2git", "lib/svn2git.rb", - "lib/svn2git/blah.rb", "lib/svn2git/migration.rb", "svn2git.gemspec" ] s.homepage = "https://www.negativetwenty.net/redmine/projects/svn2git" - s.rubygems_version = "2.2.0" + s.rubygems_version = "2.2.2" s.summary = "A tool for migrating svn projects to git" end From 13797eedc38995e093533a988336c8eefdb3ad52 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 19:35:39 -0400 Subject: [PATCH 166/204] Fixed project homepage. --- Rakefile | 2 +- svn2git.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index b57f2e9..af763e5 100644 --- a/Rakefile +++ b/Rakefile @@ -7,7 +7,7 @@ begin spec.name = "svn2git" spec.summary = "A tool for migrating svn projects to git" spec.authors = ["James Coglan", "Kevin Menard"] - spec.homepage = "https://www.negativetwenty.net/redmine/projects/svn2git" + spec.homepage = "https://github.com/nirvdrum/svn2git" spec.email = "nirvdrum@gmail.com" end Jeweler::GemcutterTasks.new diff --git a/svn2git.gemspec b/svn2git.gemspec index 6e205e9..1d867ee 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |s| "lib/svn2git/migration.rb", "svn2git.gemspec" ] - s.homepage = "https://www.negativetwenty.net/redmine/projects/svn2git" + s.homepage = "https://github.com/nirvdrum/svn2git" s.rubygems_version = "2.2.2" s.summary = "A tool for migrating svn projects to git" end From fe4e98891c5cc6abf0797bd239f978cf13e822b1 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 20:14:02 -0400 Subject: [PATCH 167/204] Added a basic test suite for flexing the escape_quotes function, which breaks almost every time I merge something. --- Rakefile | 41 ++++++++++++-------------------------- svn2git.gemspec | 12 +++++++++++ test/escape_quotes_test.rb | 22 ++++++++++++++++++++ test/test_helper.rb | 4 ++++ 4 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 test/escape_quotes_test.rb create mode 100644 test/test_helper.rb diff --git a/Rakefile b/Rakefile index af763e5..3b12559 100644 --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ require 'rake' +require 'rake/testtask' require 'rubygems/package_task' begin @@ -9,37 +10,21 @@ begin spec.authors = ["James Coglan", "Kevin Menard"] spec.homepage = "https://github.com/nirvdrum/svn2git" spec.email = "nirvdrum@gmail.com" + spec.add_development_dependency 'test-unit' end Jeweler::GemcutterTasks.new rescue LoadError puts "Jeweler not available. Install it with: gem install jeweler" end - -# -# spec = Gem::Specification.new do |spec| -# -# spec.version = "1.1.0" -# spec.platform = Gem::Platform::RUBY -# -# -# spec.require_path = "lib" -# spec.files = FileList["lib/**/*"].to_a -# spec.autorequire = "lib/svn2git.rb" -# spec.bindir = "bin" -# spec.executables = ["svn2git"] -# spec.default_executable = "svn2git" -# -# -# -# -# spec.test_files = FileList["test/**/*"].to_a -# spec.has_rdoc = true -# spec.extra_rdoc_files = ["README"] -# spec.rdoc_options << "--main" << "README" << '--line-numbers' << '--inline-source' -# end -# -# Rake::GemPackageTask.new(spec) do |pkg| -# pkg.need_tar = true -# end -# + +desc 'Test the rubber plugin.' +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = true +end + +desc 'Default: run unit tests.' +task :default => :test \ No newline at end of file diff --git a/svn2git.gemspec b/svn2git.gemspec index 1d867ee..0bb48ec 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -32,5 +32,17 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/nirvdrum/svn2git" s.rubygems_version = "2.2.2" s.summary = "A tool for migrating svn projects to git" + + if s.respond_to? :specification_version then + s.specification_version = 4 + + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q, [">= 0"]) + else + s.add_dependency(%q, [">= 0"]) + end + else + s.add_dependency(%q, [">= 0"]) + end end diff --git a/test/escape_quotes_test.rb b/test/escape_quotes_test.rb new file mode 100644 index 0000000..56fe070 --- /dev/null +++ b/test/escape_quotes_test.rb @@ -0,0 +1,22 @@ +require File.expand_path(File.join(__FILE__, '..', 'test_helper')) + +class EscapeQuotesTest < Test::Unit::TestCase + def test_identity + expected = 'A string without any need to escape.' + actual = Svn2Git::Migration.escape_quotes(expected) + + assert_equal expected, actual + end + + def test_escape_single_quotes + actual = Svn2Git::Migration.escape_quotes("Here's a message with 'single quotes.'") + + assert_equal "Here\\'s a message with \\'single quotes.\\'", actual + end + + def test_escape_double_quotes + actual = Svn2Git::Migration.escape_quotes('Here is a message with "double quotes."') + + assert_equal 'Here is a message with \\"double quotes.\\"', actual + end +end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..eac834b --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,4 @@ +$:.unshift "#{File.dirname(__FILE__)}/../lib" + +require 'svn2git' +require 'test/unit' \ No newline at end of file From ef100855b9be6f829da680499c189dc3df6ccbd1 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 20:19:19 -0400 Subject: [PATCH 168/204] Extracted escape_quotes as a class method since it doesn't rely on state. This also makes testing a bit easier. --- lib/svn2git/migration.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index d4fbbe2..72adf6a 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -145,6 +145,14 @@ def parse(args) options end + def self.escape_quotes(str) + str.gsub("'", "'\\\\''") + end + + def escape_quotes(str) + Svn2Git::Migration.escape_quotes(str) + end + private def clone! @@ -374,10 +382,6 @@ def verify_working_tree_is_clean end end - def escape_quotes(str) - str.gsub("'", "'\\\\''") - end - def git_config_command if @git_config_command.nil? status = run_command('git config --local --get user.name', false) From 4ddcfa57f9799ded9f7f8d84f998cd51fd88ed7a Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 20:19:54 -0400 Subject: [PATCH 169/204] Fixed single quote escaping and added double quote escaping. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 72adf6a..ccb18bd 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -146,7 +146,7 @@ def parse(args) end def self.escape_quotes(str) - str.gsub("'", "'\\\\''") + str.gsub(/'|"/) { |c| "\\#{c}" } end def escape_quotes(str) From b64420a83d78eb0c5b4818471fff061899f71dd1 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 20:22:58 -0400 Subject: [PATCH 170/204] Preparing the 2.2.5 release. --- ChangeLog.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 8e9cc83..8fc011b 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,8 @@ +# 2.2.5 - 2014-04-09 + + * Fixed an with single quote escaping (thanks aucl). + * Escape double quotes (e.g., if they appear in a commit message) before passing to the shell (thanks aucl). + # 2.2.4 - 2014-04-08 There was a permissions problem with some of the files packed in 2.2.3. This was caught immediately after the gem From d75725b5f1b62fcb7821d682ea73556ff1839787 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 20:27:38 -0400 Subject: [PATCH 171/204] Version bump to 2.2.5 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 2dd9e2b..88eadf9 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- :major: 2 :minor: 2 -:patch: 4 +:patch: 5 :build: From ed0c50e058bcdff54b0901e1b981815e16fefcdd Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 20:28:22 -0400 Subject: [PATCH 172/204] We're in March, not April. --- ChangeLog.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 8fc011b..2999acc 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,15 +1,15 @@ -# 2.2.5 - 2014-04-09 +# 2.2.5 - 2014-03-09 * Fixed an with single quote escaping (thanks aucl). * Escape double quotes (e.g., if they appear in a commit message) before passing to the shell (thanks aucl). -# 2.2.4 - 2014-04-08 +# 2.2.4 - 2014-03-08 There was a permissions problem with some of the files packed in 2.2.3. This was caught immediately after the gem was pushed, so it was yanked as it simply wouldn't work for anyone. 2.2.4 contains everything 2.2.3 did, but with proper packaging. -# 2.2.3 - 2014-04-08 +# 2.2.3 - 2014-03-08 This is a bugfix release. First change done by FeeJai From fdb4c9431428cc294468383c88a8ec46216dbec8 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 20:28:42 -0400 Subject: [PATCH 173/204] Updated gemspec for 2.2.5. --- svn2git.gemspec | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 0bb48ec..f7501e2 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,16 +2,16 @@ # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- -# stub: svn2git 2.2.4 ruby lib +# stub: svn2git 2.2.5 ruby lib Gem::Specification.new do |s| s.name = "svn2git" - s.version = "2.2.4" + s.version = "2.2.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] s.authors = ["James Coglan", "Kevin Menard"] - s.date = "2014-03-09" + s.date = "2014-03-10" s.email = "nirvdrum@gmail.com" s.executables = ["svn2git"] s.extra_rdoc_files = [ @@ -27,7 +27,9 @@ Gem::Specification.new do |s| "bin/svn2git", "lib/svn2git.rb", "lib/svn2git/migration.rb", - "svn2git.gemspec" + "svn2git.gemspec", + "test/escape_quotes_test.rb", + "test/test_helper.rb" ] s.homepage = "https://github.com/nirvdrum/svn2git" s.rubygems_version = "2.2.2" From e9105bc5e10ec0eefecf0d4fa09318b21d5dc9b9 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 20:29:17 -0400 Subject: [PATCH 174/204] Ignore ruby version files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 677619f..8dac8cb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ pkg .idea +.ruby-version From bbcc35ddf3c4b3491b1d471b52714a1b9525629b Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 9 Mar 2014 21:25:41 -0400 Subject: [PATCH 175/204] Added note about 2.2.5 release. --- ChangeLog.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 2999acc..0041283 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,4 +1,6 @@ # 2.2.5 - 2014-03-09 + This is a bugfix release. It improves handling of quotes in SVN commit messages. + * Fixed an with single quote escaping (thanks aucl). * Escape double quotes (e.g., if they appear in a commit message) before passing to the shell (thanks aucl). From c3e6fa6f3a5c49d756b7fb8864d3ff9c04e9a3ed Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Tue, 8 Apr 2014 11:01:16 -0500 Subject: [PATCH 176/204] add MIT license metadata to gemspec --- Rakefile | 1 + svn2git.gemspec | 1 + 2 files changed, 2 insertions(+) diff --git a/Rakefile b/Rakefile index 3b12559..5db81f1 100644 --- a/Rakefile +++ b/Rakefile @@ -11,6 +11,7 @@ begin spec.homepage = "https://github.com/nirvdrum/svn2git" spec.email = "nirvdrum@gmail.com" spec.add_development_dependency 'test-unit' + spec.license 'MIT' end Jeweler::GemcutterTasks.new diff --git a/svn2git.gemspec b/svn2git.gemspec index f7501e2..a89cad2 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -34,6 +34,7 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/nirvdrum/svn2git" s.rubygems_version = "2.2.2" s.summary = "A tool for migrating svn projects to git" + s.license = "MIT" if s.respond_to? :specification_version then s.specification_version = 4 From b8c5b799aded191657f23cdbb1d6dd0464d03e44 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 13 May 2014 21:35:51 -0400 Subject: [PATCH 177/204] First pass at passing STDIN through to git-svn. This is JRuby-only currently. We'll need to rely on the open4 lib to get non-JRuby support. --- lib/svn2git/migration.rb | 53 +++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index ccb18bd..061de96 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -340,23 +340,54 @@ def run_command(cmd, exit_on_error=true, printout_output=false) log "Running command: #{cmd}" ret = '' + mutex = Mutex.new - cmd = "2>&1 #{cmd}" - IO.popen(cmd) do |stdout| - if printout_output - stdout.each_char do |character| - $stdout.print character - ret << character - end - else + status = IO.popen4(cmd) do |pid, stdin, stdout, stderr| + threads = [] + + threads << Thread.new(stdout) do |stdout| stdout.each do |line| - log line - ret << line + mutex.synchronize do + ret << line + + if printout_output + $stdout.print line + else + log line + end + end + end + end + + threads << Thread.new(stderr) do |stderr| + stderr.each(' ') do |word| + mutex.synchronize do + ret << word + + if printout_output + $stdout.print word + else + log word + end + end end end + + threads << Thread.new(stdin) do |stdin| + user_reply = $stdin.gets.chomp + stdin.puts user_reply + stdin.close + end + + threads.each(&:join) end - if exit_on_error && ($?.exitstatus != 0) + # JRuby's open4 doesn't return a Process::Status object when invoked with a block, but rather returns the + # block expression's value. The Process::Status is stored as $?, so we need to normalize the status + # object if on JRuby. + status = $? if defined?(JRUBY_VERSION) + + if exit_on_error && (status.exitstatus != 0) $stderr.puts "command failed:\n#{cmd}" exit -1 end From 1568be4e51db9592e7543668c8378ad0d0733243 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 13 May 2014 22:03:32 -0400 Subject: [PATCH 178/204] Added a dependency on open4 to get STDIN pass-through working on MRI. --- Rakefile | 1 + lib/svn2git/migration.rb | 5 ++++- svn2git.gemspec | 21 ++++++++++++--------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Rakefile b/Rakefile index 3b12559..07496dc 100644 --- a/Rakefile +++ b/Rakefile @@ -11,6 +11,7 @@ begin spec.homepage = "https://github.com/nirvdrum/svn2git" spec.email = "nirvdrum@gmail.com" spec.add_development_dependency 'test-unit' + spec.add_dependency 'open4' end Jeweler::GemcutterTasks.new diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 061de96..42c5e7f 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -1,5 +1,6 @@ require 'optparse' require 'pp' +require 'open4' module Svn2Git DEFAULT_AUTHORS_FILE = "~/.svn2git/authors" @@ -342,7 +343,9 @@ def run_command(cmd, exit_on_error=true, printout_output=false) ret = '' mutex = Mutex.new - status = IO.popen4(cmd) do |pid, stdin, stdout, stderr| + # Open4 forks, which JRuby doesn't support. But JRuby added a popen4-compatible method on the IO class, + # so we can use that instead. + status = (defined?(JRUBY_VERSION) ? IO : Open4).popen4(cmd) do |pid, stdin, stdout, stderr| threads = [] threads << Thread.new(stdout) do |stdout| diff --git a/svn2git.gemspec b/svn2git.gemspec index f7501e2..e474c9c 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,17 +2,16 @@ # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- -# stub: svn2git 2.2.5 ruby lib Gem::Specification.new do |s| - s.name = "svn2git" + s.name = %q{svn2git} s.version = "2.2.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib"] s.authors = ["James Coglan", "Kevin Menard"] - s.date = "2014-03-10" - s.email = "nirvdrum@gmail.com" + s.date = %q{2014-05-13} + s.default_executable = %q{svn2git} + s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] s.extra_rdoc_files = [ "ChangeLog.markdown", @@ -31,20 +30,24 @@ Gem::Specification.new do |s| "test/escape_quotes_test.rb", "test/test_helper.rb" ] - s.homepage = "https://github.com/nirvdrum/svn2git" - s.rubygems_version = "2.2.2" - s.summary = "A tool for migrating svn projects to git" + s.homepage = %q{https://github.com/nirvdrum/svn2git} + s.require_paths = ["lib"] + s.rubygems_version = %q{1.6.2} + s.summary = %q{A tool for migrating svn projects to git} if s.respond_to? :specification_version then - s.specification_version = 4 + s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_development_dependency(%q, [">= 0"]) + s.add_runtime_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) end end From 925f4bc78f5b434a9b2d238f3f7a8f889c3a4b13 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Tue, 13 May 2014 22:15:52 -0400 Subject: [PATCH 179/204] Don't join on the stdin pass-through thread. Since the thread would otherwise block forever waiting for user input, we'll wrap it in a timeout and loop checking the status of the sub-process STDIN pipe. This should prevent runaway thread growth. --- lib/svn2git/migration.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 42c5e7f..7039968 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -1,6 +1,7 @@ require 'optparse' require 'pp' require 'open4' +require 'timeout' module Svn2Git DEFAULT_AUTHORS_FILE = "~/.svn2git/authors" @@ -376,10 +377,12 @@ def run_command(cmd, exit_on_error=true, printout_output=false) end end - threads << Thread.new(stdin) do |stdin| - user_reply = $stdin.gets.chomp - stdin.puts user_reply - stdin.close + Thread.new(stdin) do |stdin| + until $stdin.closed? + user_reply = Timeout.timeout(5) { $stdin.gets.chomp } + stdin.puts user_reply + stdin.close + end end threads.each(&:join) From 0e653a746a7eca65105ce94eaf5b94104d5ceb85 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 14 May 2014 13:22:42 -0400 Subject: [PATCH 180/204] Robust STDIN pass-through to sub-process. My previous attempt at preventing explosive thread growth didn't work because I couldn't reliably interrupt a .gets call. The timeout in the thread did cause the thread to begin aborting, but would still be blocked. Starting multiple such threads meant any user input could end up being consumed by any one of those threads. Moving towards a single thread for getting user input and communicating to a new pass-through thread via a Queue avoids those problems and allows us to stop the pass-through threads when they're no longer needed. --- lib/svn2git/migration.rb | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 7039968..c062faf 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -342,7 +342,15 @@ def run_command(cmd, exit_on_error=true, printout_output=false) log "Running command: #{cmd}" ret = '' - mutex = Mutex.new + @mutex ||= Mutex.new + @stdin_queue ||= Queue.new + + # We need to fetch input from the user to pass through to the underlying sub-process. We'll constantly listen + # for input and place any received values on a queue for consumption by a pass-through thread that will forward + # the contents to the underlying sub-process's stdin pipe. + @stdin_thread ||= Thread.new do + loop { @stdin_queue << $stdin.gets.chomp } + end # Open4 forks, which JRuby doesn't support. But JRuby added a popen4-compatible method on the IO class, # so we can use that instead. @@ -351,7 +359,7 @@ def run_command(cmd, exit_on_error=true, printout_output=false) threads << Thread.new(stdout) do |stdout| stdout.each do |line| - mutex.synchronize do + @mutex.synchronize do ret << line if printout_output @@ -364,8 +372,12 @@ def run_command(cmd, exit_on_error=true, printout_output=false) end threads << Thread.new(stderr) do |stderr| + # git-svn seems to do all of its prompting for user input via STDERR. When it prompts for input, it will + # not terminate the line with a newline character, so we can't split the input up by newline. It will, + # however, use a space to separate the user input from the prompt. So we split on word boundaries here + # while draining STDERR. stderr.each(' ') do |word| - mutex.synchronize do + @mutex.synchronize do ret << word if printout_output @@ -377,15 +389,24 @@ def run_command(cmd, exit_on_error=true, printout_output=false) end end + # Simple pass-through thread to take anything the user types via STDIN and passes it through to the + # sub-process's stdin pipe. Thread.new(stdin) do |stdin| - until $stdin.closed? - user_reply = Timeout.timeout(5) { $stdin.gets.chomp } + loop do + user_reply = @stdin_queue.pop + + # nil is our cue to stop looping (pun intended). + break if user_reply.nil? + stdin.puts user_reply stdin.close end end threads.each(&:join) + + # Push nil to the stdin_queue to gracefully exit the STDIN pass-through thread. + @stdin_queue << nil end # JRuby's open4 doesn't return a Process::Status object when invoked with a block, but rather returns the From 877632a03a4b108659eab9088a654c99f809caf1 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 14 May 2014 15:42:57 -0400 Subject: [PATCH 181/204] Preparing the 2.3.0 release. --- ChangeLog.markdown | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 0041283..91551cf 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,10 @@ +# 2.3.0 - 2014-05-14 + This release passes STDIN through to the underlying git-svn process, allowing users to interact with the + git-svn prompt. Principally, it will allow users to choose what to do when prompted about unverified + SSL certificates. + + * Pass STDIN through to the underlying git-svn process so users can respond to prompts. + # 2.2.5 - 2014-03-09 This is a bugfix release. It improves handling of quotes in SVN commit messages. From f725f1ad467948171d8ea00221eef2701cc95f2f Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 14 May 2014 15:43:03 -0400 Subject: [PATCH 182/204] Version bump to 2.3.0 --- VERSION.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION.yml b/VERSION.yml index 88eadf9..1eb78c5 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- :major: 2 -:minor: 2 -:patch: 5 +:minor: 3 +:patch: 0 :build: From 48720aed5a83125bafbba865ed6f6e0777a7108e Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 14 May 2014 15:43:14 -0400 Subject: [PATCH 183/204] Regenerate gemspec for version 2.3.0 --- svn2git.gemspec | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index e474c9c..192aaa8 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,16 +2,17 @@ # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- +# stub: svn2git 2.3.0 ruby lib Gem::Specification.new do |s| - s.name = %q{svn2git} - s.version = "2.2.5" + s.name = "svn2git" + s.version = "2.3.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib"] s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2014-05-13} - s.default_executable = %q{svn2git} - s.email = %q{nirvdrum@gmail.com} + s.date = "2014-05-14" + s.email = "nirvdrum@gmail.com" s.executables = ["svn2git"] s.extra_rdoc_files = [ "ChangeLog.markdown", @@ -30,13 +31,12 @@ Gem::Specification.new do |s| "test/escape_quotes_test.rb", "test/test_helper.rb" ] - s.homepage = %q{https://github.com/nirvdrum/svn2git} - s.require_paths = ["lib"] - s.rubygems_version = %q{1.6.2} - s.summary = %q{A tool for migrating svn projects to git} + s.homepage = "https://github.com/nirvdrum/svn2git" + s.rubygems_version = "2.2.2" + s.summary = "A tool for migrating svn projects to git" if s.respond_to? :specification_version then - s.specification_version = 3 + s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_development_dependency(%q, [">= 0"]) From ac4ad7eefd8e551063e7317503790dbba4d50e80 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 14 May 2014 21:44:41 -0400 Subject: [PATCH 184/204] Fixed verbose logging of sub-process STDERR stream. --- lib/svn2git/migration.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index c062faf..a0d2bac 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -339,7 +339,7 @@ def optimize_repos end def run_command(cmd, exit_on_error=true, printout_output=false) - log "Running command: #{cmd}" + log "Running command: #{cmd}\n" ret = '' @mutex ||= Mutex.new @@ -423,7 +423,7 @@ def run_command(cmd, exit_on_error=true, printout_output=false) end def log(msg) - puts msg if @options[:verbose] + print msg if @options[:verbose] end def show_help_message(msg) From 94b82b79ac71b56af3221da5174ba21f6020df11 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Wed, 14 May 2014 22:01:44 -0400 Subject: [PATCH 185/204] Apparently the license stanza ordering is important in Ruby 2.1.x. --- Rakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 041a92f..b5cd05f 100644 --- a/Rakefile +++ b/Rakefile @@ -10,9 +10,9 @@ begin spec.authors = ["James Coglan", "Kevin Menard"] spec.homepage = "https://github.com/nirvdrum/svn2git" spec.email = "nirvdrum@gmail.com" + spec.license = 'MIT' spec.add_development_dependency 'test-unit' spec.add_dependency 'open4' - spec.license 'MIT' end Jeweler::GemcutterTasks.new From 85106f78bbb1ae1191f5da2b656f670010438bd3 Mon Sep 17 00:00:00 2001 From: Ken Dreyer Date: Tue, 8 Apr 2014 11:07:20 -0500 Subject: [PATCH 186/204] tests: switch to minitest Ruby 1.9+ uses Minitest as the backend for Test::Unit. As of Minitest 5, the shim no longer supports Test::Unit::TestCase. Adjust the svn2git test suite to support Minitest 5's syntax. Minitest versions 4 and below do not support the newer Minitest::Test class that arrived in version 5. For that case, use the MiniTest::Unit::TestCase class as a fallback. --- Rakefile | 2 +- svn2git.gemspec | 6 +++--- test/escape_quotes_test.rb | 2 +- test/test_helper.rb | 10 +++++++++- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Rakefile b/Rakefile index b5cd05f..dc15789 100644 --- a/Rakefile +++ b/Rakefile @@ -11,7 +11,7 @@ begin spec.homepage = "https://github.com/nirvdrum/svn2git" spec.email = "nirvdrum@gmail.com" spec.license = 'MIT' - spec.add_development_dependency 'test-unit' + spec.add_development_dependency 'minitest' spec.add_dependency 'open4' end Jeweler::GemcutterTasks.new diff --git a/svn2git.gemspec b/svn2git.gemspec index 595c193..e11977a 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -40,14 +40,14 @@ Gem::Specification.new do |s| s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then - s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) s.add_runtime_dependency(%q, [">= 0"]) else - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end else - s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end end diff --git a/test/escape_quotes_test.rb b/test/escape_quotes_test.rb index 56fe070..3f5150c 100644 --- a/test/escape_quotes_test.rb +++ b/test/escape_quotes_test.rb @@ -1,6 +1,6 @@ require File.expand_path(File.join(__FILE__, '..', 'test_helper')) -class EscapeQuotesTest < Test::Unit::TestCase +class EscapeQuotesTest < Minitest::Test def test_identity expected = 'A string without any need to escape.' actual = Svn2Git::Migration.escape_quotes(expected) diff --git a/test/test_helper.rb b/test/test_helper.rb index eac834b..8327638 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,4 +1,12 @@ $:.unshift "#{File.dirname(__FILE__)}/../lib" +require 'rubygems' require 'svn2git' -require 'test/unit' \ No newline at end of file +require 'minitest/autorun' + +if Minitest.const_defined?('Test') + # We're on Minitest 5+. Nothing to do here. +else + # Minitest 4 doesn't have Minitest::Test yet. + Minitest::Test = MiniTest::Unit::TestCase +end \ No newline at end of file From 5842a2a4570fe111ca26e39b153a651be3358480 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Thu, 15 May 2014 00:31:13 -0400 Subject: [PATCH 187/204] Fixed issue attempting to track remote SVN branches in git >= 1.8.3.2. In order not to break semantics with those using svn2git with git < 1.8.3.2, the current tracking behavior is preserved but deprecated. Its functionality is superceded by our '--rebase' option for re-syncing with upstream. --- lib/svn2git/migration.rb | 36 ++++++++++++++++++++++++++++++++++-- test/commands_test.rb | 9 +++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 test/commands_test.rb diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index a0d2bac..3c82574 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -155,6 +155,10 @@ def escape_quotes(str) Svn2Git::Migration.escape_quotes(str) end + def self.checkout_svn_branch(branch) + "git checkout -b \"#{branch}\" \"remotes/svn/#{branch}\"" + end + private def clone! @@ -318,8 +322,36 @@ def fix_branches end next if branch == 'trunk' || @local.include?(branch) - run_command("git branch --track \"#{branch}\" \"remotes/svn/#{branch}\"") - run_command("git checkout \"#{branch}\"") + + if @cannot_setup_tracking_information + run_command(Svn2Git::Migration.checkout_svn_branch(branch)) + else + status = run_command("git branch --track \"#{branch}\" \"remotes/svn/#{branch}\"", false) + + # As of git 1.8.3.2, tracking information cannot be set up for remote SVN branches: + # http://git.661346.n2.nabble.com/git-svn-Use-prefix-by-default-td7594288.html#a7597159 + # + # Older versions of git can do it and it should be safe as long as remotes aren't pushed. + # Our --rebase option obviates the need for read-only tracked remotes, however. So, we'll + # deprecate the old option, informing those relying on the old behavior that they should + # use the newer --rebase otion. + if status =~ /Cannot setup tracking information/m + @cannot_setup_tracking_information = true + run_command(Svn2Git::Migration.checkout_svn_branch(branch)) + else + unless @legacy_svn_branch_tracking_message_displayed + warn '*' * 68 + warn "svn2git warning: Tracking remote SVN branches is deprecated." + warn "In a future release local branches will be created without tracking." + warn "If you must resync your branches, run: svn2git --rebase" + warn '*' * 68 + end + + @legacy_svn_branch_tracking_message_displayed = true + + run_command("git checkout \"#{branch}\"") + end + end end end diff --git a/test/commands_test.rb b/test/commands_test.rb new file mode 100644 index 0000000..c28b4f5 --- /dev/null +++ b/test/commands_test.rb @@ -0,0 +1,9 @@ +require File.expand_path(File.join(__FILE__, '..', 'test_helper')) + +class CommandsTest < Minitest::Test + def test_checkout_svn_branch + actual = Svn2Git::Migration.checkout_svn_branch('blah') + + assert_equal 'git checkout -b "blah" "remotes/svn/blah"', actual + end +end \ No newline at end of file From 2483cecd942e68cddc40772c1430961f2e3a1195 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Thu, 15 May 2014 00:48:20 -0400 Subject: [PATCH 188/204] Preparing the 2.3.1 release. --- ChangeLog.markdown | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 91551cf..30458da 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,4 +1,27 @@ +# 2.3.1 - 2014-05-14 + + This is a critical bugfix release if you're running git >= 1.8.3.2. In the days of svn2git 1.x we supported syncing + local branches with upstream by tracking the branch as we set them up. This allowed one to checkout the branch and + issue a "git pull" to fetch the changes. git-svn ceased allowing this in 1.8.3.2, which broke svn2git with that + version of git and all subsequent versions. The rationale seemed to be in order to prevent pushing changes from + git-svn back up and breaking the remote link, but this was never something svn2git supported anyway. + + Acknowledging the new reality of upstream, the old behavior is retained but deprecated for users of git < 1.8.3.2. + We'll be removing the establishment of remote tracking SVN branches in the 2.5.0 release. If you wish to sync back + with upstream, run `svn2git --rebase`. If you're on git >= 1.8.3.2 your only option for resynchronizing is to + use `svn2git --rebase`. + + Many thanks to ktdreyer for modernizing the test suite and Daniel Ruf (DanielRuf) for pushing on the git compatibility + issue. + + * Fixed creating local branches for remote SVN branches in git >= 1.8.3.2. + * Fixed verbose logging of sub-process STDERR stream. + * Added MIT license metadata to gemspec. + * Switched to minitest to get tests working on Ruby 1.9+ with minitest 5+ installed. + + # 2.3.0 - 2014-05-14 + This release passes STDIN through to the underlying git-svn process, allowing users to interact with the git-svn prompt. Principally, it will allow users to choose what to do when prompted about unverified SSL certificates. @@ -6,6 +29,7 @@ * Pass STDIN through to the underlying git-svn process so users can respond to prompts. # 2.2.5 - 2014-03-09 + This is a bugfix release. It improves handling of quotes in SVN commit messages. @@ -20,7 +44,7 @@ # 2.2.3 - 2014-03-08 - This is a bugfix release. First change done by FeeJai + This is a bugfix release. First change done by FeeJai. * Fixed an issue with password protected svn-repositories. The prompt to enter the password is now displayed. * Fixed an issue with server certificates. If the certificate is untrusted, the prompt to confirm or deny the certificate is now shown. From bf2a79a4c7891d1d6c7e28ee0c1d46cde1bb2c1a Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Thu, 15 May 2014 00:49:44 -0400 Subject: [PATCH 189/204] Version bump to 2.3.1 --- VERSION.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION.yml b/VERSION.yml index 1eb78c5..9e880db 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ --- :major: 2 :minor: 3 -:patch: 0 +:patch: 1 :build: From d3570dc4ac91e6a44c14a17d8076bc1ea74958a9 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Thu, 15 May 2014 00:50:17 -0400 Subject: [PATCH 190/204] Regenerate gemspec for version 2.3.1 --- svn2git.gemspec | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index e11977a..391e2cc 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,17 +2,16 @@ # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- -# stub: svn2git 2.3.0 ruby lib Gem::Specification.new do |s| - s.name = "svn2git" - s.version = "2.3.0" + s.name = %q{svn2git} + s.version = "2.3.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.require_paths = ["lib"] s.authors = ["James Coglan", "Kevin Menard"] - s.date = "2014-05-14" - s.email = "nirvdrum@gmail.com" + s.date = %q{2014-05-15} + s.default_executable = %q{svn2git} + s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] s.extra_rdoc_files = [ "ChangeLog.markdown", @@ -28,16 +27,18 @@ Gem::Specification.new do |s| "lib/svn2git.rb", "lib/svn2git/migration.rb", "svn2git.gemspec", + "test/commands_test.rb", "test/escape_quotes_test.rb", "test/test_helper.rb" ] - s.homepage = "https://github.com/nirvdrum/svn2git" - s.rubygems_version = "2.2.2" - s.summary = "A tool for migrating svn projects to git" - s.license = "MIT" + s.homepage = %q{https://github.com/nirvdrum/svn2git} + s.licenses = ["MIT"] + s.require_paths = ["lib"] + s.rubygems_version = %q{1.6.2} + s.summary = %q{A tool for migrating svn projects to git} if s.respond_to? :specification_version then - s.specification_version = 4 + s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_development_dependency(%q, [">= 0"]) From d19b9c8136ea6a3b64259c469e24ade4a2980423 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 8 Jun 2014 11:01:44 -0400 Subject: [PATCH 191/204] Switched back from open4 to IO.popen. open4 was added as a dependency when I was trying to parse STDERR and needed to work with STDIN. As it turns out, $stdin is good enough. Redirecting STDERR to STDOUT seems to be good enough as well. While open4 is probably still a cleaner approach, its reliance on fork() means it doesn't work on non-JRuby in Windows (echnically it doesn't work in JRuby either, but JRuby has an IO.popen4 special method that does virtually the same thing and we were using that instead). --- Rakefile | 1 - lib/svn2git/migration.rb | 45 ++++++++++------------------------------ 2 files changed, 11 insertions(+), 35 deletions(-) diff --git a/Rakefile b/Rakefile index dc15789..80abf54 100644 --- a/Rakefile +++ b/Rakefile @@ -12,7 +12,6 @@ begin spec.email = "nirvdrum@gmail.com" spec.license = 'MIT' spec.add_development_dependency 'minitest' - spec.add_dependency 'open4' end Jeweler::GemcutterTasks.new diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 3c82574..f27a57d 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -1,6 +1,5 @@ require 'optparse' require 'pp' -require 'open4' require 'timeout' module Svn2Git @@ -374,7 +373,6 @@ def run_command(cmd, exit_on_error=true, printout_output=false) log "Running command: #{cmd}\n" ret = '' - @mutex ||= Mutex.new @stdin_queue ||= Queue.new # We need to fetch input from the user to pass through to the underlying sub-process. We'll constantly listen @@ -386,44 +384,28 @@ def run_command(cmd, exit_on_error=true, printout_output=false) # Open4 forks, which JRuby doesn't support. But JRuby added a popen4-compatible method on the IO class, # so we can use that instead. - status = (defined?(JRUBY_VERSION) ? IO : Open4).popen4(cmd) do |pid, stdin, stdout, stderr| + IO.popen("2>&1 #{cmd}") do |output| threads = [] - threads << Thread.new(stdout) do |stdout| - stdout.each do |line| - @mutex.synchronize do - ret << line - - if printout_output - $stdout.print line - else - log line - end - end - end - end - - threads << Thread.new(stderr) do |stderr| + threads << Thread.new(output) do |output| # git-svn seems to do all of its prompting for user input via STDERR. When it prompts for input, it will # not terminate the line with a newline character, so we can't split the input up by newline. It will, # however, use a space to separate the user input from the prompt. So we split on word boundaries here # while draining STDERR. - stderr.each(' ') do |word| - @mutex.synchronize do - ret << word - - if printout_output - $stdout.print word - else - log word - end + output.each(' ') do |word| + ret << word + + if printout_output + $stdout.print word + else + log word end end end # Simple pass-through thread to take anything the user types via STDIN and passes it through to the # sub-process's stdin pipe. - Thread.new(stdin) do |stdin| + Thread.new do loop do user_reply = @stdin_queue.pop @@ -441,12 +423,7 @@ def run_command(cmd, exit_on_error=true, printout_output=false) @stdin_queue << nil end - # JRuby's open4 doesn't return a Process::Status object when invoked with a block, but rather returns the - # block expression's value. The Process::Status is stored as $?, so we need to normalize the status - # object if on JRuby. - status = $? if defined?(JRUBY_VERSION) - - if exit_on_error && (status.exitstatus != 0) + if exit_on_error && $?.exitstatus != 0 $stderr.puts "command failed:\n#{cmd}" exit -1 end From e3a590665be5f87d1bb4738c4907f9b00c70984d Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 8 Jun 2014 11:22:29 -0400 Subject: [PATCH 192/204] Ruby 1.8.7 requires explicit requiring of 'thread' in order to use Queue. --- lib/svn2git/migration.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index f27a57d..89d6828 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -1,6 +1,7 @@ require 'optparse' require 'pp' require 'timeout' +require 'thread' module Svn2Git DEFAULT_AUTHORS_FILE = "~/.svn2git/authors" From 68d702b04bd9eca9d748e9e0e2de4c4ee391e010 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 8 Jun 2014 11:27:49 -0400 Subject: [PATCH 193/204] Preparing the 2.3.2 release. --- ChangeLog.markdown | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index 30458da..a85ba48 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,11 @@ +# 2.3.2 - 2014-06-08 + + This is a bugfix release. It fixes issues running with Windows using MRI ruby and fixes a problem with Ruby 1.8.7. + + * Removed open4 dependency. svn2git no longer has any runtime dependencies and things work well on Windows again. + * Fixed an issue with Ruby 1.8.7, which doesn't implicitly require the 'thread' library meaning classes that library weren't in scope. + + # 2.3.1 - 2014-05-14 This is a critical bugfix release if you're running git >= 1.8.3.2. In the days of svn2git 1.x we supported syncing From 6168dbe322a8f875abd163b4e54e5b30afbbed06 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 8 Jun 2014 11:28:06 -0400 Subject: [PATCH 194/204] Preparing the 2.3.2 release. --- VERSION.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VERSION.yml b/VERSION.yml index 9e880db..15110c2 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ ---- -:major: 2 -:minor: 3 -:patch: 1 +--- :build: +:minor: 3 +:patch: 2 +:major: 2 From 21ace8b755bded2eaf70a5cacb61b6989b07cf8d Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 8 Jun 2014 11:28:11 -0400 Subject: [PATCH 195/204] Regenerate gemspec for version 2.3.2 --- svn2git.gemspec | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 391e2cc..5c9ee4a 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -5,11 +5,11 @@ Gem::Specification.new do |s| s.name = %q{svn2git} - s.version = "2.3.1" + s.version = "2.3.2" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2014-05-15} + s.date = %q{2014-06-08} s.default_executable = %q{svn2git} s.email = %q{nirvdrum@gmail.com} s.executables = ["svn2git"] @@ -42,14 +42,11 @@ Gem::Specification.new do |s| if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_development_dependency(%q, [">= 0"]) - s.add_runtime_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 0"]) - s.add_dependency(%q, [">= 0"]) end end From e3d7d8084a793769e2026d432f7d62a325c1a220 Mon Sep 17 00:00:00 2001 From: Paul Sexton Date: Fri, 1 Aug 2014 14:47:38 -0500 Subject: [PATCH 196/204] Update README.markdown On Debian systems, the `rubygems` package has been rolled into the `ruby` package. --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 81f2257..6041c47 100644 --- a/README.markdown +++ b/README.markdown @@ -66,7 +66,7 @@ Installation Make sure you have git, git-svn, and ruby installed. svn2git is a ruby wrapper around git's native SVN support through git-svn. It is possible to have git installed without git-svn installed, so please do verify that you can run `$ git svn` successfully. For a Debian-based system, the installation of the prerequisites would look like: - $ sudo apt-get install git-core git-svn ruby rubygems + $ sudo apt-get install git-core git-svn ruby Once you have the necessary software on your system, you can install svn2git through rubygems, which will add the `svn2git` command to your PATH. From f90c69a7c8adcf0042f14a6f69b30059920ff580 Mon Sep 17 00:00:00 2001 From: Ed Date: Thu, 16 Apr 2015 10:43:57 +0100 Subject: [PATCH 197/204] Stop README ID-extract snippet leaving spaces end of line --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 81f2257..e8c341e 100644 --- a/README.markdown +++ b/README.markdown @@ -176,11 +176,11 @@ repository which name on its own line. This would allow you to easily redirect the output of this command sequence to `~/.svn2git/authors` and have a very good starting point for your mapping. - $ svn log --quiet | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/^ //' | sort | uniq + $ svn log --quiet | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/ //g' | sort | uniq Or, for a remote URL: - $ svn log --quiet http://path/to/root/of/project | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/^ //' | sort | uniq + $ svn log --quiet http://path/to/root/of/project | grep -E "r[0-9]+ \| .+ \|" | cut -d'|' -f2 | sed 's/ //g' | sort | uniq Debugging --------- From 39704bd0d95fde7326b57a89f3e395ba087b3f8a Mon Sep 17 00:00:00 2001 From: Ed Date: Wed, 15 Apr 2015 15:15:01 +0100 Subject: [PATCH 198/204] Add support for --password option --- README.markdown | 5 +++++ lib/svn2git/migration.rb | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/README.markdown b/README.markdown index ad0beb0..9eb4740 100644 --- a/README.markdown +++ b/README.markdown @@ -118,6 +118,10 @@ one of them. $ svn2git http://svn.example.com/path/to/repo --username <> +If this doesn't cooperate and you need to specify a password on the command-line: + + $ svn2git http://svn.example.com/path/to/repo --username <> --password <> + 8. You need to migrate starting at a specific svn revision number. $ svn2git http://svn.example.com/path/to/repo --revision <> @@ -202,6 +206,7 @@ Options Reference Specific options: --rebase Instead of cloning a new project, rebase an existing one against SVN --username NAME Username for transports that needs it (http(s), svn) + --password PASS Password for transports that needs it (http(s), svn) --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) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 89d6828..bd0f6b2 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -52,6 +52,7 @@ def parse(args) options[:exclude] = [] options[:revision] = nil options[:username] = nil + options[:password] = nil options[:rebasebranch] = false if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE)) @@ -74,6 +75,10 @@ def parse(args) options[:username] = username end + opts.on('--password PASSWORD', 'Password for transports that need it (http(s), svn)') do |password| + options[:password] = password + end + opts.on('--trunk TRUNK_PATH', 'Subpath to trunk from repository URL (default: trunk)') do |trunk| options[:trunk] = trunk end @@ -172,11 +177,13 @@ def clone! exclude = @options[:exclude] revision = @options[:revision] username = @options[:username] + password = @options[:password] if rootistrunk # Non-standard repository layout. The repository root is effectively 'trunk.' cmd = "git svn init --prefix=svn/ " cmd += "--username=#{username} " unless username.nil? + cmd += "--password=#{password} " unless password.nil? cmd += "--no-metadata " unless metadata if nominimizeurl cmd += "--no-minimize-url " @@ -189,6 +196,7 @@ def clone! # Add each component to the command that was passed as an argument. cmd += "--username=#{username} " unless username.nil? + cmd += "--password=#{password} " unless password.nil? cmd += "--no-metadata " unless metadata if nominimizeurl cmd += "--no-minimize-url " From 7b52a1c0224e02f370ee5a8026ea0417434c37ea Mon Sep 17 00:00:00 2001 From: Peter Fern Date: Fri, 1 Jul 2016 15:21:58 +1000 Subject: [PATCH 199/204] Fix exclude arg (incorrectly quoted string) The quote in the appended `--ignore-paths` cmd argument is in the wrong place. Also add the conventional space in case of additional future args. --- lib/svn2git/migration.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index bd0f6b2..5158b7a 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -228,7 +228,7 @@ def clone! regex << "#{branches}[/][^/]+[/]" unless branches.nil? end regex = '^(?:' + regex.join('|') + ')(?:' + exclude.join('|') + ')' - cmd += "'--ignore-paths=#{regex}'" + cmd += "--ignore-paths='#{regex}' " end run_command(cmd, true, true) From 3dea2bf91ee3bacd1cba4b0edc3fe8a185487edb Mon Sep 17 00:00:00 2001 From: Peter Fern Date: Tue, 5 Jul 2016 16:01:20 +1000 Subject: [PATCH 200/204] Allow `tags` and `branches` arguments to be specified multiple times This mirrors upstream, though I'm not certain of which git-svn version this functionality was added. Fixes #175 --- lib/svn2git/migration.rb | 46 ++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/lib/svn2git/migration.rb b/lib/svn2git/migration.rb index 5158b7a..4de8a9e 100755 --- a/lib/svn2git/migration.rb +++ b/lib/svn2git/migration.rb @@ -47,8 +47,8 @@ def parse(args) options[:nominimizeurl] = false options[:rootistrunk] = false options[:trunk] = 'trunk' - options[:branches] = 'branches' - options[:tags] = 'tags' + options[:branches] = [] + options[:tags] = [] options[:exclude] = [] options[:revision] = nil options[:username] = nil @@ -83,12 +83,12 @@ def parse(args) options[:trunk] = trunk end - opts.on('--branches BRANCHES_PATH', 'Subpath to branches from repository URL (default: branches)') do |branches| - options[:branches] = branches + opts.on('--branches BRANCHES_PATH', 'Subpath to branches from repository URL (default: branches); can be used multiple times') do |branches| + options[:branches] << branches end - opts.on('--tags TAGS_PATH', 'Subpath to tags from repository URL (default: tags)') do |tags| - options[:tags] = tags + opts.on('--tags TAGS_PATH', 'Subpath to tags from repository URL (default: tags); can be used multiple times') do |tags| + options[:tags] << tags 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 @@ -182,28 +182,42 @@ def clone! if rootistrunk # Non-standard repository layout. The repository root is effectively 'trunk.' cmd = "git svn init --prefix=svn/ " - cmd += "--username=#{username} " unless username.nil? - cmd += "--password=#{password} " unless password.nil? + cmd += "--username='#{username}' " unless username.nil? + cmd += "--password='#{password}' " unless password.nil? cmd += "--no-metadata " unless metadata if nominimizeurl cmd += "--no-minimize-url " end - cmd += "--trunk=#{@url}" + cmd += "--trunk='#{@url}'" run_command(cmd, true, true) else cmd = "git svn init --prefix=svn/ " # Add each component to the command that was passed as an argument. - cmd += "--username=#{username} " unless username.nil? - cmd += "--password=#{password} " unless password.nil? + cmd += "--username='#{username}' " unless username.nil? + cmd += "--password='#{password}' " unless password.nil? cmd += "--no-metadata " unless metadata if nominimizeurl cmd += "--no-minimize-url " end - cmd += "--trunk=#{trunk} " unless trunk.nil? - cmd += "--tags=#{tags} " unless tags.nil? - cmd += "--branches=#{branches} " unless branches.nil? + cmd += "--trunk='#{trunk}' " unless trunk.nil? + unless tags.nil? + # Fill default tags here so that they can be filtered later + tags = ['tags'] if tags.empty? + # Process default or user-supplied tags + tags.each do |tag| + cmd += "--tags='#{tag}' " + end + end + unless branches.nil? + # Fill default branches here so that they can be filtered later + branches = ['branches'] if branches.empty? + # Process default or user-supplied branches + branches.each do |branch| + cmd += "--branches='#{branch}' " + end + end cmd += @url @@ -224,8 +238,8 @@ def clone! regex = [] unless rootistrunk regex << "#{trunk}[/]" unless trunk.nil? - regex << "#{tags}[/][^/]+[/]" unless tags.nil? - regex << "#{branches}[/][^/]+[/]" unless branches.nil? + tags.each{|tag| regex << "#{tag}[/][^/]+[/]"} unless tags.nil? or tags.empty? + branches.each{|branch| regex << "#{branch}[/][^/]+[/]"} unless branches.nil? or branches.empty? end regex = '^(?:' + regex.join('|') + ')(?:' + exclude.join('|') + ')' cmd += "--ignore-paths='#{regex}' " From 243705abc86c3bfd904852da69e24b781f5a368d Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 30 Oct 2016 10:13:02 -0400 Subject: [PATCH 201/204] Updated README to note that '--branches' and '--tags' can be passed multiple times. --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 9eb4740..7b1165c 100644 --- a/README.markdown +++ b/README.markdown @@ -208,8 +208,8 @@ Options Reference --username NAME Username for transports that needs it (http(s), svn) --password PASS Password for transports that needs it (http(s), svn) --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) + --branches BRANCHES_PATH Subpath to branches from repository URL (default: branches); can be used multiple times + --tags TAGS_PATH Subpath to tags from repository URL (default: tags); can be used multiple times --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 From 39d1f6e29c6c8b4be6ac1b02d2c409209b44c905 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 30 Oct 2016 10:14:24 -0400 Subject: [PATCH 202/204] Preparing the 2.4.0 release. --- ChangeLog.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ChangeLog.markdown b/ChangeLog.markdown index a85ba48..f8d7239 100644 --- a/ChangeLog.markdown +++ b/ChangeLog.markdown @@ -1,3 +1,13 @@ +# 2.4.0 - 2016-10-30 + + This release introduces the ability to supply a password for SVN repositories that can't authenticate by other means. + It also adds the ability to specify the '--branches' and '--tags' arguments multiple times to better support those with + more complicated SVN repository layouts. + + * Added support for the '--password' option for authentication (thanks edpbx). + * Added the ability to specify the '--branches' and '--tags' arguments multiple times (thanks pdf). + * Fixed a problem with processing of the '--exclude' argument (improper quoting internally) (thanks pdf). + # 2.3.2 - 2014-06-08 This is a bugfix release. It fixes issues running with Windows using MRI ruby and fixes a problem with Ruby 1.8.7. From d3eab20cb1ddfdaf66498d83e2bc239e859c9c2b Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 30 Oct 2016 10:14:41 -0400 Subject: [PATCH 203/204] Version bump to 2.4.0 --- VERSION.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VERSION.yml b/VERSION.yml index 15110c2..900900f 100644 --- a/VERSION.yml +++ b/VERSION.yml @@ -1,5 +1,5 @@ ---- -:build: -:minor: 3 -:patch: 2 +--- :major: 2 +:minor: 4 +:patch: 0 +:build: From 6dac85ad12b74b478a926f09db0b110d73838702 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Sun, 30 Oct 2016 10:15:26 -0400 Subject: [PATCH 204/204] Regenerate gemspec for version 2.4.0 --- svn2git.gemspec | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/svn2git.gemspec b/svn2git.gemspec index 5c9ee4a..c5a786f 100644 --- a/svn2git.gemspec +++ b/svn2git.gemspec @@ -2,16 +2,17 @@ # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- +# stub: svn2git 2.4.0 ruby lib Gem::Specification.new do |s| - s.name = %q{svn2git} - s.version = "2.3.2" + s.name = "svn2git" + s.version = "2.4.0" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.require_paths = ["lib"] s.authors = ["James Coglan", "Kevin Menard"] - s.date = %q{2014-06-08} - s.default_executable = %q{svn2git} - s.email = %q{nirvdrum@gmail.com} + s.date = "2016-10-30" + s.email = "nirvdrum@gmail.com" s.executables = ["svn2git"] s.extra_rdoc_files = [ "ChangeLog.markdown", @@ -31,14 +32,13 @@ Gem::Specification.new do |s| "test/escape_quotes_test.rb", "test/test_helper.rb" ] - s.homepage = %q{https://github.com/nirvdrum/svn2git} + s.homepage = "https://github.com/nirvdrum/svn2git" s.licenses = ["MIT"] - s.require_paths = ["lib"] - s.rubygems_version = %q{1.6.2} - s.summary = %q{A tool for migrating svn projects to git} + s.rubygems_version = "2.5.1" + s.summary = "A tool for migrating svn projects to git" if s.respond_to? :specification_version then - s.specification_version = 3 + s.specification_version = 4 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_development_dependency(%q, [">= 0"])