mss-svn2git 1.2.4 → 1.2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +46 -45
- data/lib/svn2git/migration.rb +11 -12
- metadata +1 -1
data/README.markdown
CHANGED
@@ -13,50 +13,50 @@ Examples
|
|
13
13
|
|
14
14
|
Say I have this code in svn:
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
27
|
|
28
28
|
git-svn will go through the commit history to build a new git repo. It will
|
29
29
|
import all branches and tags as remote svn branches, whereas what you really
|
30
30
|
want is git-native local branches and git tag objects. So after importing this
|
31
31
|
project I'll get:
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
47
|
|
48
48
|
After svn2git is done with your project, you'll get this instead:
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
60
|
|
61
61
|
Finally, it makes sure the HEAD of master is the same as the current trunk of
|
62
62
|
the svn repo.
|
@@ -80,28 +80,28 @@ create a git repo from a svn repo in the specified layout.
|
|
80
80
|
1. The svn repo is in the standard layout of (trunk, branches, tags) at the
|
81
81
|
root level of the repo.
|
82
82
|
|
83
|
-
|
83
|
+
$ svn2git http://svn.example.com/path/to/repo
|
84
84
|
|
85
85
|
2. The svn repo is NOT in standard layout and has only a trunk and tags at the
|
86
86
|
root level of the repo.
|
87
87
|
|
88
|
-
|
88
|
+
$ svn2git http://svn.example.com/path/to/repo --trunk trunk --tags tags
|
89
89
|
|
90
90
|
3. The svn repo is NOT in standard layout and has only a trunk and branches at
|
91
91
|
the root level of the repo.
|
92
92
|
|
93
|
-
|
93
|
+
$ svn2git http://svn.example.com/path/to/repo --trunk trunk --branches branches
|
94
94
|
|
95
95
|
4. The svn repo is NOT in standard layout and has only a trunk at the root
|
96
96
|
level of the repo.
|
97
97
|
|
98
|
-
|
98
|
+
$ svn2git http://svn.example.com/path/to/repo --trunk trunk
|
99
99
|
|
100
100
|
5. The svn repo is NOT in standard layout and has no trunk, branches, or tags
|
101
101
|
at the root level of the repo. Instead the root level of the repo is
|
102
102
|
equivalent to the trunk and there are no tags or branches.
|
103
103
|
|
104
|
-
|
104
|
+
$ svn2git http://svn.example.com/path/to/repo --rootistrunk
|
105
105
|
|
106
106
|
The above will create a git repository in the current directory with the git
|
107
107
|
version of the svn repository. Hence, you need to make a directory that you
|
@@ -109,7 +109,7 @@ want your new git repo to exist in, change into it and then run one of the
|
|
109
109
|
above commands. Note that in the above cases the trunk, branches, tags options
|
110
110
|
are simply folder names relative to the provided repo path. For example if you
|
111
111
|
specified trunk=foo branches=bar and tags=foobar it would be referencing
|
112
|
-
http://svn.
|
112
|
+
http://svn.example.com/path/to/repo/foo as your trunk, and so on. However, in
|
113
113
|
case 5 it references the root of the repo as trunk.
|
114
114
|
|
115
115
|
Authors
|
@@ -118,12 +118,12 @@ Authors
|
|
118
118
|
To convert all your svn authors to git format, create a file somewhere on your
|
119
119
|
system with the list of conversions to make, one per line, for example:
|
120
120
|
|
121
|
-
|
122
|
-
|
121
|
+
jcoglan = James Coglan <jcoglan@never-you-mind.com>
|
122
|
+
stnick = Santa Claus <nicholas@lapland.com>
|
123
123
|
|
124
124
|
Then pass an +authors+ option to +svn2git+ pointing to your file:
|
125
125
|
|
126
|
-
|
126
|
+
$ svn2git http://svn.example.com/path/to/repo --authors ~/authors.txt
|
127
127
|
|
128
128
|
Alternatively, you can place the authors file into ~/.svn2git/authors and
|
129
129
|
svn2git will load it out of there. This allows you to build up one authors
|
@@ -139,4 +139,5 @@ underlying git-svn process.
|
|
139
139
|
|
140
140
|
You can turn on verbose logging with the '-v' or '--verbose' flags, like so:
|
141
141
|
|
142
|
-
|
142
|
+
$ svn2git http://svn.yoursite.com/path/to/repo --verbose
|
143
|
+
|
data/lib/svn2git/migration.rb
CHANGED
@@ -61,7 +61,7 @@ module Svn2Git
|
|
61
61
|
options[:authors] = authors
|
62
62
|
end
|
63
63
|
|
64
|
-
opts.on('--rootistrunk', 'Use this if the root level of the repo
|
64
|
+
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
|
65
65
|
options[:rootistrunk] = true
|
66
66
|
end
|
67
67
|
|
@@ -92,22 +92,20 @@ module Svn2Git
|
|
92
92
|
rootistrunk = @options[:rootistrunk]
|
93
93
|
authors = @options[:authors]
|
94
94
|
|
95
|
+
cmd = %w{git svn init --no-metadata}
|
95
96
|
if rootistrunk
|
96
97
|
# Non-standard repository layout. The repository root is effectively 'trunk.'
|
97
|
-
|
98
|
+
cmd << "--trunk=#{@url}"
|
98
99
|
|
99
100
|
else
|
100
|
-
cmd = "git svn init --no-metadata "
|
101
|
-
|
102
101
|
# Add each component to the command that was passed as an argument.
|
103
|
-
cmd
|
104
|
-
cmd
|
105
|
-
cmd
|
106
|
-
|
107
|
-
cmd += @url
|
102
|
+
cmd << "--trunk=#{trunk}" unless trunk.nil?
|
103
|
+
cmd << "--tags=#{tags}" unless tags.nil?
|
104
|
+
cmd << "--branches=#{branches}" unless branches.nil?
|
108
105
|
|
109
|
-
|
106
|
+
cmd << @url
|
110
107
|
end
|
108
|
+
run_command(cmd)
|
111
109
|
|
112
110
|
run_command("git config svn.authorsfile #{authors}") if authors
|
113
111
|
run_command("git svn fetch")
|
@@ -125,8 +123,7 @@ module Svn2Git
|
|
125
123
|
id = tag.strip.gsub(%r{^#{@options[:tags]}\/}, '')
|
126
124
|
subject = `git log -1 --pretty=format:"%s" #{tag.strip()}`
|
127
125
|
date = `git log -1 --pretty=format:"%ci" #{tag.strip()}`
|
128
|
-
|
129
|
-
run_command("git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}'")
|
126
|
+
run_command("GIT_COMMITTER_DATE='#{date}' git tag -a -m '#{subject}' '#{id.strip()}' '#{tag.strip()}'")
|
130
127
|
run_command("git branch -d -r #{tag.strip()}")
|
131
128
|
end
|
132
129
|
end
|
@@ -156,6 +153,8 @@ module Svn2Git
|
|
156
153
|
end
|
157
154
|
|
158
155
|
def run_command(cmd)
|
156
|
+
cmd = cmd.join(' ') if cmd.kind_of? Array
|
157
|
+
|
159
158
|
log "Running command: #{cmd}"
|
160
159
|
|
161
160
|
IO.popen(cmd) do |stdout|
|