svn2git 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.markdown CHANGED
@@ -1,3 +1,13 @@
1
+ # 2.1.0 - 2011-04-03
2
+
3
+ Thanks to Francois Rey (fmjrey), Sven Axelsson (svenax), and Julian Taylor (juliantaylor) for submitting all the patches
4
+ that comprise this release. svn2git now works with a much wider array SVN repositories because of their efforts.
5
+
6
+ * Added --no-minimize-url option for migrating specific subprojects from an SVN repo containing several projects (thanks fmjrey).
7
+ * Added --username option for migrating password-protected repositories (thanks svenax).
8
+ * Added --revision option for specifying the revision to start importing from (thanks svenax).
9
+ * Fixed compatibility with older versions of git (thanks juliantaylor).
10
+
1
11
  # 2.0.0 - 2010-05-29
2
12
 
3
13
  This release adds the oft requested incremental SVN update support. If you run svn2git with the `--rebase` option on an existing
data/README.markdown CHANGED
@@ -107,6 +107,19 @@ doc directory and the backup files you once accidently added.
107
107
 
108
108
  $ svn2git http://svn.example.com/path/to/repo --exclude doc --exclude '.*~$'
109
109
 
110
+ 6. The svn repo actually tracks several projects and you only want to migrate
111
+ one of them.
112
+
113
+ $ svn2git http://svn.example.com/path/to/repo/nested_project --no-minimize-url
114
+
115
+ 7. The svn repo is password protected.
116
+
117
+ $ svn2git http://svn.example.com/path/to/repo --username <<user_with_perms>>
118
+
119
+ 8. You need to migrate starting at a specific svn revision number.
120
+
121
+ $ svn2git http://svn.example.com/path/to/repo --revision <<starting_revision_number>>
122
+
110
123
  The above will create a git repository in the current directory with the git
111
124
  version of the svn repository. Hence, you need to make a directory that you
112
125
  want your new git repo to exist in, change into it and then run one of the
@@ -153,7 +166,7 @@ repository which name on its own line. This would allow you to easily
153
166
  redirect the output of this command sequence to ~/.svn2git/authors and have
154
167
  a very good starting point for your mapping.
155
168
 
156
- $ svn log | grep -E "r[0-9]+ \| [a-z]+ \|" | awk '{print $3}' | sort | uniq
169
+ $ svn log | grep -E "r[0-9]+ \| .+ \|" | awk '{print $3}' | sort | uniq
157
170
 
158
171
  Debugging
159
172
  ---------
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :build:
3
2
  :patch: 0
3
+ :build:
4
4
  :major: 2
5
- :minor: 0
5
+ :minor: 1
@@ -36,11 +36,15 @@ module Svn2Git
36
36
  # Set up reasonable defaults for options.
37
37
  options = {}
38
38
  options[:verbose] = false
39
+ options[:metadata] = false
40
+ options[:nominimizeurl] = false
39
41
  options[:rootistrunk] = false
40
42
  options[:trunk] = 'trunk'
41
43
  options[:branches] = 'branches'
42
44
  options[:tags] = 'tags'
43
45
  options[:exclude] = []
46
+ options[:revision] = nil
47
+ options[:username] = nil
44
48
 
45
49
  if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE))
46
50
  options[:authors] = DEFAULT_AUTHORS_FILE
@@ -58,6 +62,10 @@ module Svn2Git
58
62
  options[:rebase] = true
59
63
  end
60
64
 
65
+ opts.on('--username NAME', 'Username for transports that needs it (http(s), svn)') do |username|
66
+ options[:username] = username
67
+ end
68
+
61
69
  opts.on('--trunk TRUNK_PATH', 'Subpath to trunk from repository URL (default: trunk)') do |trunk|
62
70
  options[:trunk] = trunk
63
71
  end
@@ -65,6 +73,7 @@ module Svn2Git
65
73
  opts.on('--branches BRANCHES_PATH', 'Subpath to branches from repository URL (default: branches)') do |branches|
66
74
  options[:branches] = branches
67
75
  end
76
+
68
77
  opts.on('--tags TAGS_PATH', 'Subpath to tags from repository URL (default: tags)') do |tags|
69
78
  options[:tags] = tags
70
79
  end
@@ -88,6 +97,18 @@ module Svn2Git
88
97
  options[:tags] = nil
89
98
  end
90
99
 
100
+ opts.on('--no-minimize-url', 'Accept URLs as-is without attempting to connect to a higher level directory') do
101
+ options[:nominimizeurl] = true
102
+ end
103
+
104
+ opts.on('--revision REV', 'Start importing from SVN revision') do |revision|
105
+ options[:revision] = revision
106
+ end
107
+
108
+ opts.on('-m', '--metadata', 'Include metadata in git logs (git-svn-id)') do
109
+ options[:metadata] = true
110
+ end
111
+
91
112
  opts.on('--authors AUTHORS_FILE', "Path to file containing svn-to-git authors mapping (default: #{DEFAULT_AUTHORS_FILE})") do |authors|
92
113
  options[:authors] = authors
93
114
  end
@@ -120,18 +141,34 @@ module Svn2Git
120
141
  trunk = @options[:trunk]
121
142
  branches = @options[:branches]
122
143
  tags = @options[:tags]
144
+ metadata = @options[:metadata]
145
+ nominimizeurl = @options[:nominimizeurl]
123
146
  rootistrunk = @options[:rootistrunk]
124
147
  authors = @options[:authors]
125
148
  exclude = @options[:exclude]
149
+ revision = @options[:revision]
150
+ username = @options[:username]
126
151
 
127
152
  if rootistrunk
128
153
  # Non-standard repository layout. The repository root is effectively 'trunk.'
129
- run_command("git svn init --no-metadata --trunk=#{@url}")
154
+ cmd = "git svn init --prefix=svn/ "
155
+ cmd += "--username=#{username} " unless username.nil?
156
+ cmd += "--no-metadata " unless metadata
157
+ if nominimizeurl
158
+ cmd += "--no-minimize-url "
159
+ end
160
+ cmd += "--trunk=#{@url}"
161
+ run_command(cmd)
130
162
 
131
163
  else
132
- cmd = "git svn init --no-metadata "
164
+ cmd = "git svn init --prefix=svn/ "
133
165
 
134
166
  # Add each component to the command that was passed as an argument.
167
+ cmd += "--username=#{username} " unless username.nil?
168
+ cmd += "--no-metadata " unless metadata
169
+ if nominimizeurl
170
+ cmd += "--no-minimize-url "
171
+ end
135
172
  cmd += "--trunk=#{trunk} " unless trunk.nil?
136
173
  cmd += "--tags=#{tags} " unless tags.nil?
137
174
  cmd += "--branches=#{branches} " unless branches.nil?
@@ -143,7 +180,8 @@ module Svn2Git
143
180
 
144
181
  run_command("git config svn.authorsfile #{authors}") unless authors.nil?
145
182
 
146
- cmd = "git svn fetch"
183
+ cmd = "git svn fetch "
184
+ cmd += "-r #{revision}:HEAD " unless revision.nil?
147
185
  unless exclude.empty?
148
186
  # Add exclude paths to the command line; some versions of git support
149
187
  # this for fetch only, later also for init.
@@ -154,7 +192,7 @@ module Svn2Git
154
192
  regex << "#{branches}[/][^/]+[/]" unless branches.nil?
155
193
  end
156
194
  regex = '^(?:' + regex.join('|') + ')(?:' + exclude.join('|') + ')'
157
- cmd += " '--ignore-paths=#{regex}'"
195
+ cmd += "'--ignore-paths=#{regex}'"
158
196
  end
159
197
  run_command(cmd)
160
198
 
@@ -168,13 +206,13 @@ module Svn2Git
168
206
  @remote = run_command("git branch -r --no-color").split(/\n/).collect{ |b| b.gsub(/\*/,'').strip }
169
207
 
170
208
  # Tags are remote branches that start with "tags/".
171
- @tags = @remote.find_all { |b| b.strip =~ %r{^tags\/} }
209
+ @tags = @remote.find_all { |b| b.strip =~ %r{^svn\/tags\/} }
172
210
  end
173
211
 
174
212
  def fix_tags
175
213
  @tags.each do |tag|
176
214
  tag = tag.strip
177
- id = tag.gsub(%r{^tags\/}, '').strip
215
+ id = tag.gsub(%r{^svn\/tags\/}, '').strip
178
216
  subject = run_command("git log -1 --pretty=format:'%s' #{tag}")
179
217
  date = run_command("git log -1 --pretty=format:'%ci' #{tag}")
180
218
  subject = escape_quotes(subject)
@@ -187,18 +225,24 @@ module Svn2Git
187
225
 
188
226
  def fix_branches
189
227
  svn_branches = @remote.find_all { |b| not @tags.include?(b) }
190
- svn_branches.each do |branch|
191
- branch = branch.strip
228
+ svn_branches = @remote.find_all { |b| b.strip =~ %r{^svn\/} }
192
229
 
230
+ if @options[:rebase]
231
+ run_command("git svn fetch")
232
+ end
233
+
234
+ svn_branches.each do |branch|
235
+ branch = branch.gsub(/^svn\//,'').strip
193
236
  if @options[:rebase] && (@local.include?(branch) || branch == 'trunk')
194
- branch = 'master' if branch == 'trunk'
195
- run_command("git checkout -f #{branch}")
196
- run_command("git svn rebase")
237
+ lbranch = branch
238
+ lbranch = 'master' if branch == 'trunk'
239
+ run_command("git checkout -f #{lbranch}")
240
+ run_command("git rebase remotes/svn/#{branch}")
197
241
  next
198
242
  end
199
243
 
200
- next if branch == 'trunk'
201
- run_command("git branch -t #{branch} remotes/#{branch}")
244
+ next if branch == 'trunk' || @local.include?(branch)
245
+ run_command("git branch --track #{branch} remotes/svn/#{branch}")
202
246
  run_command("git checkout #{branch}")
203
247
  end
204
248
  end
@@ -206,7 +250,7 @@ module Svn2Git
206
250
  def fix_trunk
207
251
  trunk = @remote.find { |b| b.strip == 'trunk' }
208
252
  if trunk && ! @options[:rebase]
209
- run_command("git checkout trunk")
253
+ run_command("git checkout svn/trunk")
210
254
  run_command("git branch -D master")
211
255
  run_command("git checkout -f -b master")
212
256
  else
@@ -229,7 +273,7 @@ module Svn2Git
229
273
  ret << line
230
274
  end
231
275
  end
232
-
276
+
233
277
  ret
234
278
  end
235
279
 
@@ -242,12 +286,12 @@ module Svn2Git
242
286
  puts @opts.help
243
287
  exit
244
288
  end
245
-
289
+
246
290
  def verify_working_tree_is_clean
247
291
  status = run_command('git status --porcelain --untracked-files=no')
248
292
  unless status.strip == ''
249
293
  puts 'You have local pending changes. The working tree must be clean in order to continue.'
250
- exit
294
+ exit -1
251
295
  end
252
296
  end
253
297
 
data/svn2git.gemspec CHANGED
@@ -1,43 +1,40 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{svn2git}
8
- s.version = "2.0.0"
8
+ s.version = "2.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Coglan", "Kevin Menard"]
12
- s.date = %q{2010-05-29}
12
+ s.date = %q{2011-04-03}
13
13
  s.default_executable = %q{svn2git}
14
14
  s.email = %q{nirvdrum@gmail.com}
15
15
  s.executables = ["svn2git"]
16
16
  s.extra_rdoc_files = [
17
17
  "ChangeLog.markdown",
18
- "README.markdown"
18
+ "README.markdown"
19
19
  ]
20
20
  s.files = [
21
- ".gitignore",
22
- "ChangeLog.markdown",
23
- "MIT-LICENSE",
24
- "README.markdown",
25
- "Rakefile",
26
- "VERSION.yml",
27
- "bin/svn2git",
28
- "lib/svn2git.rb",
29
- "lib/svn2git/blah.rb",
30
- "lib/svn2git/migration.rb",
31
- "svn2git.gemspec"
21
+ "ChangeLog.markdown",
22
+ "MIT-LICENSE",
23
+ "README.markdown",
24
+ "Rakefile",
25
+ "VERSION.yml",
26
+ "bin/svn2git",
27
+ "lib/svn2git.rb",
28
+ "lib/svn2git/blah.rb",
29
+ "lib/svn2git/migration.rb",
30
+ "svn2git.gemspec"
32
31
  ]
33
32
  s.homepage = %q{https://www.negativetwenty.net/redmine/projects/svn2git}
34
- s.rdoc_options = ["--charset=UTF-8"]
35
33
  s.require_paths = ["lib"]
36
- s.rubygems_version = %q{1.3.7}
34
+ s.rubygems_version = %q{1.5.3}
37
35
  s.summary = %q{A tool for migrating svn projects to git}
38
36
 
39
37
  if s.respond_to? :specification_version then
40
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
41
38
  s.specification_version = 3
42
39
 
43
40
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svn2git
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
5
- prerelease: false
4
+ hash: 11
5
+ prerelease:
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 0
10
- version: 2.0.0
10
+ version: 2.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Coglan
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-05-29 00:00:00 -04:00
19
+ date: 2011-04-03 00:00:00 -04:00
20
20
  default_executable: svn2git
21
21
  dependencies: []
22
22
 
@@ -30,7 +30,6 @@ extra_rdoc_files:
30
30
  - ChangeLog.markdown
31
31
  - README.markdown
32
32
  files:
33
- - .gitignore
34
33
  - ChangeLog.markdown
35
34
  - MIT-LICENSE
36
35
  - README.markdown
@@ -46,8 +45,8 @@ homepage: https://www.negativetwenty.net/redmine/projects/svn2git
46
45
  licenses: []
47
46
 
48
47
  post_install_message:
49
- rdoc_options:
50
- - --charset=UTF-8
48
+ rdoc_options: []
49
+
51
50
  require_paths:
52
51
  - lib
53
52
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -71,7 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
70
  requirements: []
72
71
 
73
72
  rubyforge_project:
74
- rubygems_version: 1.3.7
73
+ rubygems_version: 1.5.3
75
74
  signing_key:
76
75
  specification_version: 3
77
76
  summary: A tool for migrating svn projects to git
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- pkg
2
- .idea