svn2git 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/ChangeLog.markdown +53 -0
- data/MIT-LICENSE +20 -0
- data/README.markdown +172 -0
- data/Rakefile +44 -0
- data/VERSION.yml +4 -0
- data/bin/svn2git +26 -0
- data/lib/svn2git.rb +2 -0
- data/lib/svn2git/migration.rb +213 -0
- data/svn2git.gemspec +44 -0
- metadata +66 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
pkg
|
data/ChangeLog.markdown
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# 1.3.1 - 2009-06-09
|
2
|
+
|
3
|
+
Thanks to iteman for finding a problem with the tagging process and providing a patch.
|
4
|
+
|
5
|
+
* Fixed a problem with creating actual git tags when the SVN tags path was named anything other than 'tags.'
|
6
|
+
|
7
|
+
# 1.3.0 - 2009-06-09
|
8
|
+
|
9
|
+
Many thanks to mss for the patches making up most of this release.
|
10
|
+
|
11
|
+
* Fixed a problem where tags didn't get the original date and time.
|
12
|
+
* New switch --exclude which can be used to specify a PCRE pattern to exclude paths from the import.
|
13
|
+
* New switches --no{trunk,branches,tags} to skip import of those.
|
14
|
+
* Improved docs.
|
15
|
+
|
16
|
+
# 1.2.4 - 2009-05-04
|
17
|
+
|
18
|
+
* No changes. I ran the jeweler command twice inadvertently. Tearing down the release would be more harmful than helpful.
|
19
|
+
|
20
|
+
# 1.2.3 - 2009-05-04
|
21
|
+
|
22
|
+
* Yanked out the code referencing the gem by name. This shouldn't be necessary at all.
|
23
|
+
|
24
|
+
# 1.2.2 - 2009-05-04
|
25
|
+
|
26
|
+
* Updated the reference gem in the binary to use this one and not the one on RubyForge.
|
27
|
+
|
28
|
+
# 1.2.1 - 2009-04-19
|
29
|
+
|
30
|
+
* Fixed a problem with the svn2git binary not loading command-line args properly.
|
31
|
+
|
32
|
+
# 1.2.0 - 2009-04-17
|
33
|
+
|
34
|
+
* Reworked command-line options so they work similarly to every other app in the world.
|
35
|
+
* Better error messaging when no URL provided.
|
36
|
+
* Improved docs.
|
37
|
+
|
38
|
+
# 1.1.1 - 2009-04-15
|
39
|
+
|
40
|
+
* Started using Jeweler for gem management.
|
41
|
+
* Fixed issue with not loading up RubyGems appropriately.
|
42
|
+
|
43
|
+
# 1.1.0 - 2009-01-02
|
44
|
+
|
45
|
+
* First release since nirvdrum fork.
|
46
|
+
|
47
|
+
* Fixed issues with handling of tags and branches.
|
48
|
+
* Added better logging of output from git-svn.
|
49
|
+
* Wrap external command processing to capture failures.
|
50
|
+
|
51
|
+
# 1.0.0 - 2008-07-19
|
52
|
+
|
53
|
+
* Forked version from jcoglan.
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 James Coglan, Kevin Menard
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
20
|
+
|
data/README.markdown
ADDED
@@ -0,0 +1,172 @@
|
|
1
|
+
svn2git
|
2
|
+
=======
|
3
|
+
|
4
|
+
_svn2git_ is a tiny utility for migrating projects from Subversion to Git
|
5
|
+
while keeping the trunk, branches and tags where they should be. It uses
|
6
|
+
git-svn to clone an svn repository and does some clean-up to make sure
|
7
|
+
branches and tags are imported in a meaningful way, and that the code checked
|
8
|
+
into master ends up being what's currently in your svn trunk rather than
|
9
|
+
whichever svn branch your last commit was in.
|
10
|
+
|
11
|
+
Examples
|
12
|
+
--------
|
13
|
+
|
14
|
+
Say I have this code in svn:
|
15
|
+
|
16
|
+
trunk
|
17
|
+
...
|
18
|
+
branches
|
19
|
+
1.x
|
20
|
+
2.x
|
21
|
+
tags
|
22
|
+
1.0.0
|
23
|
+
1.0.1
|
24
|
+
1.0.2
|
25
|
+
1.1.0
|
26
|
+
2.0.0
|
27
|
+
|
28
|
+
git-svn will go through the commit history to build a new git repo. It will
|
29
|
+
import all branches and tags as remote svn branches, whereas what you really
|
30
|
+
want is git-native local branches and git tag objects. So after importing this
|
31
|
+
project I'll get:
|
32
|
+
|
33
|
+
$ git branch
|
34
|
+
* master
|
35
|
+
$ git branch -a
|
36
|
+
* master
|
37
|
+
1.x
|
38
|
+
2.x
|
39
|
+
tags/1.0.0
|
40
|
+
tags/1.0.1
|
41
|
+
tags/1.0.2
|
42
|
+
tags/1.1.0
|
43
|
+
tags/2.0.0
|
44
|
+
trunk
|
45
|
+
$ git tag -l
|
46
|
+
[ empty ]
|
47
|
+
|
48
|
+
After svn2git is done with your project, you'll get this instead:
|
49
|
+
|
50
|
+
$ git branch
|
51
|
+
* master
|
52
|
+
1.x
|
53
|
+
2.x
|
54
|
+
$ git tag -l
|
55
|
+
1.0.0
|
56
|
+
1.0.1
|
57
|
+
1.0.2
|
58
|
+
1.1.0
|
59
|
+
2.0.0
|
60
|
+
|
61
|
+
Finally, it makes sure the HEAD of master is the same as the current trunk of
|
62
|
+
the svn repo.
|
63
|
+
|
64
|
+
Installation
|
65
|
+
------------
|
66
|
+
|
67
|
+
Make sure you have git installed, then install the gem:
|
68
|
+
|
69
|
+
$ sudo apt-get install git-core git-svn
|
70
|
+
$ sudo gem install nirvdrum-svn2git
|
71
|
+
|
72
|
+
Usage
|
73
|
+
-----
|
74
|
+
|
75
|
+
There are a number of ways in which you can create a git repo from an existing
|
76
|
+
svn repo. The differentiating factor is the svn repo layout. Below is an
|
77
|
+
enumerated listing of the varying supported layouts and the proper way to
|
78
|
+
create a git repo from a svn repo in the specified layout.
|
79
|
+
|
80
|
+
1. The svn repo is in the standard layout of (trunk, branches, tags) at the
|
81
|
+
root level of the repo.
|
82
|
+
|
83
|
+
$ svn2git http://svn.example.com/path/to/repo
|
84
|
+
|
85
|
+
2. The svn repo is NOT in standard layout and has only a trunk and tags at the
|
86
|
+
root level of the repo.
|
87
|
+
|
88
|
+
$ svn2git http://svn.example.com/path/to/repo --trunk dev --tags rel --nobranches
|
89
|
+
|
90
|
+
3. The svn repo is NOT in standard layout and has only a trunk at the root
|
91
|
+
level of the repo.
|
92
|
+
|
93
|
+
$ svn2git http://svn.example.com/path/to/repo --trunk trunk --nobranches --notags
|
94
|
+
|
95
|
+
4. The svn repo is NOT in standard layout and has no trunk, branches, or tags
|
96
|
+
at the root level of the repo. Instead the root level of the repo is
|
97
|
+
equivalent to the trunk and there are no tags or branches.
|
98
|
+
|
99
|
+
$ svn2git http://svn.example.com/path/to/repo --rootistrunk
|
100
|
+
|
101
|
+
5. The svn repo is in the standard layout but you want to exclude the massive
|
102
|
+
doc directory and the backup files you once accidently added.
|
103
|
+
|
104
|
+
$ svn2git http://svn.example.com/path/to/repo --exclude doc --exclude '.*~$'
|
105
|
+
|
106
|
+
The above will create a git repository in the current directory with the git
|
107
|
+
version of the svn repository. Hence, you need to make a directory that you
|
108
|
+
want your new git repo to exist in, change into it and then run one of the
|
109
|
+
above commands. Note that in the above cases the trunk, branches, tags options
|
110
|
+
are simply folder names relative to the provided repo path. For example if you
|
111
|
+
specified trunk=foo branches=bar and tags=foobar it would be referencing
|
112
|
+
http://svn.example.com/path/to/repo/foo as your trunk, and so on. However, in
|
113
|
+
case 4 it references the root of the repo as trunk.
|
114
|
+
|
115
|
+
Authors
|
116
|
+
-------
|
117
|
+
|
118
|
+
To convert all your svn authors to git format, create a file somewhere on your
|
119
|
+
system with the list of conversions to make, one per line, for example:
|
120
|
+
|
121
|
+
jcoglan = James Coglan <jcoglan@never-you-mind.com>
|
122
|
+
stnick = Santa Claus <nicholas@lapland.com>
|
123
|
+
|
124
|
+
Then pass an +authors+ option to +svn2git+ pointing to your file:
|
125
|
+
|
126
|
+
$ svn2git http://svn.example.com/path/to/repo --authors ~/authors.txt
|
127
|
+
|
128
|
+
Alternatively, you can place the authors file into ~/.svn2git/authors and
|
129
|
+
svn2git will load it out of there. This allows you to build up one authors
|
130
|
+
file for all your projects and have it loaded for each repository that you
|
131
|
+
migrate.
|
132
|
+
|
133
|
+
Debugging
|
134
|
+
---------
|
135
|
+
|
136
|
+
If you're having problems with converting your repository and you're not sure why,
|
137
|
+
try turning on verbose logging. This will print out more information from the
|
138
|
+
underlying git-svn process.
|
139
|
+
|
140
|
+
You can turn on verbose logging with the '-v' or '--verbose' flags, like so:
|
141
|
+
|
142
|
+
$ svn2git http://svn.yoursite.com/path/to/repo --verbose
|
143
|
+
|
144
|
+
FAQ
|
145
|
+
---
|
146
|
+
|
147
|
+
1. Why don't the tags show up in the master branch?
|
148
|
+
|
149
|
+
The tags won't show up in the master branch because the tags are actually
|
150
|
+
tied to the commits that were created in svn when the user made the tag.
|
151
|
+
Those commits are the first (head) commit of branch in svn that is
|
152
|
+
associated with that tag. If you want to see all the branches and tags
|
153
|
+
and their relationships in gitk you can run the following: gitk --all
|
154
|
+
|
155
|
+
For further details please refer to FAQ #2.
|
156
|
+
|
157
|
+
2. Why don't you reference the parent of the tag commits instead?
|
158
|
+
|
159
|
+
In svn you are forced to create what are known in git as annotated tags.
|
160
|
+
It just so happens that svn annotated tags allow you to commit change
|
161
|
+
sets along with the tagging action. This means that the svn annotated tag
|
162
|
+
is a bit more complex then just an annotated tag it is a commit which is
|
163
|
+
treated as an annotated tag. Hence, for there to be a true 1-to-1 mapping
|
164
|
+
between git and svn we have to transfer over the svn commit which acts as
|
165
|
+
an annotated tag and then tag that commit in git using an annotated tag.
|
166
|
+
|
167
|
+
If we were to reference the parent of this svn tagged commit there could
|
168
|
+
potentially be situations where a developer would checkout a tag in git
|
169
|
+
and the resulting code base would be different then if they checked out
|
170
|
+
that very same tag in the original svn repo. This is only due to the fact
|
171
|
+
that the svn tags allow changesets in them, making them not just annotated
|
172
|
+
tags.
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |spec|
|
7
|
+
spec.name = "svn2git"
|
8
|
+
spec.summary = "A tool for migrating svn projects to git"
|
9
|
+
spec.authors = ["James Coglan", "Kevin Menard"]
|
10
|
+
spec.homepage = "https://www.negativetwenty.net/redmine/projects/svn2git"
|
11
|
+
spec.email = "nirvdrum@gmail.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
rescue LoadError
|
15
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# spec = Gem::Specification.new do |spec|
|
20
|
+
#
|
21
|
+
# spec.version = "1.1.0"
|
22
|
+
# spec.platform = Gem::Platform::RUBY
|
23
|
+
#
|
24
|
+
#
|
25
|
+
# spec.require_path = "lib"
|
26
|
+
# spec.files = FileList["lib/**/*"].to_a
|
27
|
+
# spec.autorequire = "lib/svn2git.rb"
|
28
|
+
# spec.bindir = "bin"
|
29
|
+
# spec.executables = ["svn2git"]
|
30
|
+
# spec.default_executable = "svn2git"
|
31
|
+
#
|
32
|
+
#
|
33
|
+
#
|
34
|
+
#
|
35
|
+
# spec.test_files = FileList["test/**/*"].to_a
|
36
|
+
# spec.has_rdoc = true
|
37
|
+
# spec.extra_rdoc_files = ["README"]
|
38
|
+
# spec.rdoc_options << "--main" << "README" << '--line-numbers' << '--inline-source'
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# Rake::GemPackageTask.new(spec) do |pkg|
|
42
|
+
# pkg.need_tar = true
|
43
|
+
# end
|
44
|
+
#
|
data/VERSION.yml
ADDED
data/bin/svn2git
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright (c) 2008 James Coglan
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'svn2git'
|
24
|
+
|
25
|
+
migration = Svn2Git::Migration.new(ARGV)
|
26
|
+
migration.run!
|
data/lib/svn2git.rb
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'pp'
|
3
|
+
|
4
|
+
module Svn2Git
|
5
|
+
DEFAULT_AUTHORS_FILE = "~/.svn2git/authors"
|
6
|
+
|
7
|
+
class Migration
|
8
|
+
|
9
|
+
attr_reader :dir
|
10
|
+
|
11
|
+
def initialize(args)
|
12
|
+
@options = parse(args)
|
13
|
+
show_help_message("Missing SVN_URL parameter") if args.empty?
|
14
|
+
show_help_message('Too many arguments') if args.size > 1
|
15
|
+
|
16
|
+
@url = args.first
|
17
|
+
end
|
18
|
+
|
19
|
+
def run!
|
20
|
+
clone!
|
21
|
+
fix_tags
|
22
|
+
fix_branches
|
23
|
+
fix_trunk
|
24
|
+
optimize_repos
|
25
|
+
end
|
26
|
+
|
27
|
+
def parse(args)
|
28
|
+
# Set up reasonable defaults for options.
|
29
|
+
options = {}
|
30
|
+
options[:verbose] = false
|
31
|
+
options[:rootistrunk] = false
|
32
|
+
options[:trunk] = 'trunk'
|
33
|
+
options[:branches] = 'branches'
|
34
|
+
options[:tags] = 'tags'
|
35
|
+
options[:exclude] = []
|
36
|
+
|
37
|
+
if File.exists?(File.expand_path(DEFAULT_AUTHORS_FILE))
|
38
|
+
options[:authors] = DEFAULT_AUTHORS_FILE
|
39
|
+
end
|
40
|
+
|
41
|
+
|
42
|
+
# Parse the command-line arguments.
|
43
|
+
@opts = OptionParser.new do |opts|
|
44
|
+
opts.banner = 'Usage: svn2git SVN_URL [options]'
|
45
|
+
|
46
|
+
opts.separator ''
|
47
|
+
opts.separator 'Specific options:'
|
48
|
+
|
49
|
+
opts.on('--trunk TRUNK_PATH', 'Subpath to trunk from repository URL (default: trunk)') do |trunk|
|
50
|
+
options[:trunk] = trunk
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on('--branches BRANCHES_PATH', 'Subpath to branches from repository URL (default: branches)') do |branches|
|
54
|
+
options[:branches] = branches
|
55
|
+
end
|
56
|
+
opts.on('--tags TAGS_PATH', 'Subpath to tags from repository URL (default: tags)') do |tags|
|
57
|
+
options[:tags] = tags
|
58
|
+
end
|
59
|
+
|
60
|
+
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
|
61
|
+
options[:rootistrunk] = true
|
62
|
+
options[:trunk] = nil
|
63
|
+
options[:branches] = nil
|
64
|
+
options[:tags] = nil
|
65
|
+
end
|
66
|
+
|
67
|
+
opts.on('--notrunk', 'Do not import anything from trunk') do
|
68
|
+
options[:trunk] = nil
|
69
|
+
end
|
70
|
+
|
71
|
+
opts.on('--nobranches', 'Do not try to import any branches') do
|
72
|
+
options[:branches] = nil
|
73
|
+
end
|
74
|
+
|
75
|
+
opts.on('--notags', 'Do not try to import any tags') do
|
76
|
+
options[:tags] = nil
|
77
|
+
end
|
78
|
+
|
79
|
+
opts.on('--authors AUTHORS_FILE', "Path to file containing svn-to-git authors mapping (default: #{DEFAULT_AUTHORS_FILE})") do |authors|
|
80
|
+
options[:authors] = authors
|
81
|
+
end
|
82
|
+
|
83
|
+
opts.on('--exclude REGEX', 'Specify a Perl regular expression to filter paths when fetching; can be used multiple times') do |regex|
|
84
|
+
options[:exclude] << regex
|
85
|
+
end
|
86
|
+
|
87
|
+
opts.on('-v', '--verbose', 'Be verbose in logging -- useful for debugging issues') do
|
88
|
+
options[:verbose] = true
|
89
|
+
end
|
90
|
+
|
91
|
+
opts.separator ""
|
92
|
+
|
93
|
+
# No argument, shows at tail. This will print an options summary.
|
94
|
+
# Try it and see!
|
95
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
96
|
+
puts opts
|
97
|
+
exit
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
@opts.parse! args
|
102
|
+
options
|
103
|
+
end
|
104
|
+
|
105
|
+
private
|
106
|
+
|
107
|
+
def clone!
|
108
|
+
trunk = @options[:trunk]
|
109
|
+
branches = @options[:branches]
|
110
|
+
tags = @options[:tags]
|
111
|
+
rootistrunk = @options[:rootistrunk]
|
112
|
+
authors = @options[:authors]
|
113
|
+
exclude = @options[:exclude]
|
114
|
+
|
115
|
+
if rootistrunk
|
116
|
+
# Non-standard repository layout. The repository root is effectively 'trunk.'
|
117
|
+
run_command("git svn init --no-metadata --trunk=#{@url}")
|
118
|
+
|
119
|
+
else
|
120
|
+
cmd = "git svn init --no-metadata "
|
121
|
+
|
122
|
+
# Add each component to the command that was passed as an argument.
|
123
|
+
cmd += "--trunk=#{trunk} " unless trunk.nil?
|
124
|
+
cmd += "--tags=#{tags} " unless tags.nil?
|
125
|
+
cmd += "--branches=#{branches} " unless branches.nil?
|
126
|
+
|
127
|
+
cmd += @url
|
128
|
+
|
129
|
+
run_command(cmd)
|
130
|
+
end
|
131
|
+
|
132
|
+
run_command("git config svn.authorsfile #{authors}") if authors
|
133
|
+
|
134
|
+
cmd = "git svn fetch"
|
135
|
+
unless exclude.empty?
|
136
|
+
# Add exclude paths to the command line; some versions of git support
|
137
|
+
# this for fetch only, later also for init.
|
138
|
+
regex = []
|
139
|
+
unless rootistrunk
|
140
|
+
regex << "#{trunk}[/]" unless trunk.nil?
|
141
|
+
regex << "#{tags}[/][^/]+[/]" unless tags.nil?
|
142
|
+
regex << "#{branches}[/][^/]+[/]" unless branches.nil?
|
143
|
+
end
|
144
|
+
regex = '^(?:' + regex.join('|') + ')(?:' + exclude.join('|') + ')'
|
145
|
+
cmd += "'--ignore-paths=#{regex}'"
|
146
|
+
end
|
147
|
+
run_command(cmd)
|
148
|
+
|
149
|
+
get_branches
|
150
|
+
end
|
151
|
+
|
152
|
+
def get_branches
|
153
|
+
@remote = `git branch -r`.split(/\n/)
|
154
|
+
@tags = @remote.find_all { |b| b.strip =~ %r{^tags\/} }
|
155
|
+
end
|
156
|
+
|
157
|
+
def fix_tags
|
158
|
+
@tags.each do |tag|
|
159
|
+
id = tag.strip.gsub(%r{^tags\/}, '')
|
160
|
+
subject = `git log -1 --pretty=format:"%s" #{tag.strip()}`
|
161
|
+
date = `git log -1 --pretty=format:"%ci" #{tag.strip()}`
|
162
|
+
run_command("GIT_COMMITTER_DATE='#{date}' git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}'")
|
163
|
+
run_command("git branch -d -r #{tag.strip()}")
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def fix_branches
|
168
|
+
svn_branches = @remote.find_all { |b| not @tags.include?(b) }
|
169
|
+
svn_branches.each do |branch|
|
170
|
+
branch = branch.strip
|
171
|
+
next if branch == 'trunk'
|
172
|
+
run_command("git checkout #{branch}")
|
173
|
+
run_command("git checkout -b #{branch}")
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def fix_trunk
|
178
|
+
trunk = @remote.find { |b| b.strip == 'trunk' }
|
179
|
+
if trunk
|
180
|
+
run_command("git checkout trunk")
|
181
|
+
run_command("git branch -D master")
|
182
|
+
run_command("git checkout -f -b master")
|
183
|
+
run_command("git branch -d -r trunk")
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
def optimize_repos
|
188
|
+
run_command("git gc")
|
189
|
+
end
|
190
|
+
|
191
|
+
def run_command(cmd)
|
192
|
+
log "Running command: #{cmd}"
|
193
|
+
|
194
|
+
IO.popen(cmd) do |stdout|
|
195
|
+
stdout.each do |line|
|
196
|
+
log line
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def log(msg)
|
202
|
+
puts msg if @options[:verbose]
|
203
|
+
end
|
204
|
+
|
205
|
+
def show_help_message(msg)
|
206
|
+
puts "Error starting script: #{msg}\n\n"
|
207
|
+
puts @opts.help
|
208
|
+
exit
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
data/svn2git.gemspec
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{svn2git}
|
5
|
+
s.version = "1.3.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["James Coglan", "Kevin Menard"]
|
9
|
+
s.date = %q{2009-06-09}
|
10
|
+
s.default_executable = %q{svn2git}
|
11
|
+
s.email = %q{nirvdrum@gmail.com}
|
12
|
+
s.executables = ["svn2git"]
|
13
|
+
s.extra_rdoc_files = [
|
14
|
+
"ChangeLog.markdown",
|
15
|
+
"README.markdown"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
".gitignore",
|
19
|
+
"ChangeLog.markdown",
|
20
|
+
"MIT-LICENSE",
|
21
|
+
"README.markdown",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION.yml",
|
24
|
+
"bin/svn2git",
|
25
|
+
"lib/svn2git.rb",
|
26
|
+
"lib/svn2git/migration.rb",
|
27
|
+
"svn2git.gemspec"
|
28
|
+
]
|
29
|
+
s.homepage = %q{https://www.negativetwenty.net/redmine/projects/svn2git}
|
30
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
31
|
+
s.require_paths = ["lib"]
|
32
|
+
s.rubygems_version = %q{1.3.4}
|
33
|
+
s.summary = %q{A tool for migrating svn projects to git}
|
34
|
+
|
35
|
+
if s.respond_to? :specification_version then
|
36
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
37
|
+
s.specification_version = 3
|
38
|
+
|
39
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
40
|
+
else
|
41
|
+
end
|
42
|
+
else
|
43
|
+
end
|
44
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: svn2git
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Coglan
|
8
|
+
- Kevin Menard
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2009-06-09 00:00:00 -04:00
|
14
|
+
default_executable: svn2git
|
15
|
+
dependencies: []
|
16
|
+
|
17
|
+
description:
|
18
|
+
email: nirvdrum@gmail.com
|
19
|
+
executables:
|
20
|
+
- svn2git
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files:
|
24
|
+
- ChangeLog.markdown
|
25
|
+
- README.markdown
|
26
|
+
files:
|
27
|
+
- .gitignore
|
28
|
+
- ChangeLog.markdown
|
29
|
+
- MIT-LICENSE
|
30
|
+
- README.markdown
|
31
|
+
- Rakefile
|
32
|
+
- VERSION.yml
|
33
|
+
- bin/svn2git
|
34
|
+
- lib/svn2git.rb
|
35
|
+
- lib/svn2git/migration.rb
|
36
|
+
- svn2git.gemspec
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: https://www.negativetwenty.net/redmine/projects/svn2git
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --charset=UTF-8
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: "0"
|
51
|
+
version:
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "0"
|
57
|
+
version:
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 1.3.4
|
62
|
+
signing_key:
|
63
|
+
specification_version: 3
|
64
|
+
summary: A tool for migrating svn projects to git
|
65
|
+
test_files: []
|
66
|
+
|