Skip to content

Commit 5ec8000

Browse files
authored
Merge pull request #34 from mazong1123/fix-22-add-readme
Updated document and xslt.
2 parents af6b216 + 883d967 commit 5ec8000

File tree

2 files changed

+224
-45
lines changed

2 files changed

+224
-45
lines changed

README.md

+162-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,165 @@
33
[![Build status](https://ci.appveyor.com/api/projects/status/g97ep0v2e9qbhemc?svg=true)](https://ci.appveyor.com/project/mazong1123/svn2gitnet)
44
[![Build status](https://travis-ci.org/mazong1123/svn2gitnet.svg?branch=master)](https://travis-ci.org/mazong1123/svn2gitnet)
55

6-
**SVN2GIT.NET** started as a .NET implementation of [svn2git](https://github.com/nirvdrum/svn2git). It intends to provide a simple and easy way to migrate projects from svn to git.
6+
**SVN2GIT.NET** started as a .NET re-implementation of [svn2git](https://github.com/nirvdrum/svn2git). It intends to provide a simple and easy way to migrate projects from svn to git.
7+
8+
It is based on `git-svn` so please make sure it has been installed.
9+
10+
## Examples
11+
12+
Say if we have this code in svn:
13+
14+
trunk
15+
...
16+
branches
17+
1.x
18+
2.x
19+
tags
20+
1.0.0
21+
1.0.1
22+
1.0.2
23+
1.1.0
24+
2.0.0
25+
26+
`git-svn` will go through the commit history to build a new git repo. It will
27+
import all branches and tags as remote svn branches, whereas what you really
28+
want is git-native local branches and git tag objects. So after importing this
29+
project we'll get:
30+
31+
$ git branch
32+
* master
33+
$ git branch -a
34+
* master
35+
1.x
36+
2.x
37+
tags/1.0.0
38+
tags/1.0.1
39+
tags/1.0.2
40+
tags/1.1.0
41+
tags/2.0.0
42+
trunk
43+
$ git tag -l
44+
[ empty ]
45+
46+
After `svn2gitnet` is done with your project, you'll get this instead:
47+
48+
$ git branch
49+
* master
50+
1.x
51+
2.x
52+
$ git tag -l
53+
1.0.0
54+
1.0.1
55+
1.0.2
56+
1.1.0
57+
2.0.0
58+
59+
Finally, it makes sure the HEAD of master is the same as the current trunk of
60+
the svn repo.
61+
62+
## Installation
63+
64+
### Windows
65+
66+
- Option 1: Download `.msi` file in the [release page](https://github.com/mazong1123/svn2gitnet/releases). Double click to install it. **Note: There's no "Next" or "Finish" button during the installation process. If it finished, just open a command line window, type `svn2gitnet --help` to verify the installation. I'll add wizard dialog during installation in the upcoming release.**
67+
68+
- Option: 2: Download `zip` file in the [release page](https://github.com/mazong1123/svn2gitnet/releases). Extract the zip, and add the folder to `PATH` environment variable. Open command line window and type `svn2gitnet --help`.
69+
70+
### Mac and *nix
71+
72+
Download the correct `tar.gz` file according to your OS.
73+
74+
Extract it via:
75+
76+
```
77+
tar -zxvf yourosname.tar.gz
78+
```
79+
80+
Add the folder to the environment path:
81+
82+
```sh
83+
PATH=$PATH:yourfolderpath
84+
```
85+
86+
Type `svn2gitnet --help` to verify the installation.
87+
88+
## How to use
89+
90+
### Initial Conversion
91+
92+
There are several ways you can create a git repo from an existing
93+
svn repo. The differentiating factor is the svn repo layout. Below is an
94+
enumerated listing of the varying supported layouts and the proper way to
95+
create a git repo from a svn repo in the specified layout.
96+
97+
1. The svn repo is in the standard layout of (trunk, branches, tags) at the
98+
root level of the repo.
99+
100+
$ svn2gitnet http://svn.example.com/path/to/repo
101+
102+
2. The svn repo is NOT in standard layout and has only a trunk and tags at the
103+
root level of the repo.
104+
105+
$ svn2gitnet http://svn.example.com/path/to/repo --trunk dev --tags rel --nobranches
106+
107+
3. The svn repo is NOT in standard layout and has only a trunk at the root
108+
level of the repo.
109+
110+
$ svn2gitnet http://svn.example.com/path/to/repo --trunk trunk --nobranches --notags
111+
112+
4. The svn repo is NOT in standard layout and has no trunk, branches, or tags
113+
at the root level of the repo. Instead the root level of the repo is
114+
equivalent to the trunk and there are no tags or branches.
115+
116+
$ svn2gitnet http://svn.example.com/path/to/repo --rootistrunk
117+
118+
5. The svn repo is in the standard layout but you want to exclude the massive
119+
doc directory and the backup files you once accidently added.
120+
121+
$ svn2gitnet http://svn.example.com/path/to/repo --exclude doc --exclude '.*~$'
122+
123+
6. The svn repo actually tracks several projects and you only want to migrate
124+
one of them.
125+
126+
$ svn2gitnet http://svn.example.com/path/to/repo/nested_project --no-minimize-url
127+
128+
7. The svn repo is password protected.
129+
130+
$ svn2gitnet http://svn.example.com/path/to/repo --username <<user_with_perms>> --password <<password>>
131+
132+
8. You need to migrate starting at a specific svn revision number.
133+
134+
$ svn2gitnet http://svn.example.com/path/to/repo --revision <<starting_revision_number>>
135+
136+
9. You need to migrate starting at a specific svn revision number, ending at a specific revision number.
137+
138+
```sh
139+
svn2gitnet http://svn.example.com/path/to/repo --revision <<starting_revision_number>>:<<ending_revision_number>>
140+
```
141+
142+
10. Include metadata (git-svn-id) in git logs.
143+
144+
```sh
145+
svn2gitnet http://svn.example.com/path/to/repo --metadata
146+
```
147+
148+
The above will create a git repository in the current directory with the git
149+
version of the svn repository. Hence, you need to make a directory that you
150+
want your new git repo to exist in, change into it and then run one of the
151+
above commands. Note that in the above cases the trunk, branches, tags options
152+
are simply folder names relative to the provided repo path. For example if you
153+
specified trunk=foo branches=bar and tags=foobar it would be referencing
154+
http://svn.example.com/path/to/repo/foo as your trunk, and so on. However, in
155+
case 4 it references the root of the repo as trunk.
156+
157+
### Repository Updates
158+
159+
to pull in the latest changes from SVN into your
160+
git repository created with svn2git. This is a one way sync, but allows you to use svn2git
161+
as a mirroring tool for your SVN repositories.
162+
163+
The command to call is:
164+
165+
```sh
166+
svn2git --rebase
167+
```

svn2gitnet.xslt

+62-44
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,63 @@
1-
<xsl:transform version="1.0"
2-
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3-
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
4-
5-
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
6-
7-
<xsl:template match="wix:Product/@Version">
8-
<xsl:attribute name="Version">1.0.0.0</xsl:attribute>
9-
</xsl:template>
10-
11-
<xsl:template match="wix:Product/@Manufacturer">
12-
<xsl:attribute name="Manufacturer">Jingyu Ma</xsl:attribute>
13-
</xsl:template>
14-
15-
<xsl:template match="wix:Product/@Name">
16-
<xsl:attribute name="Name">Svn2Git.NET</xsl:attribute>
17-
</xsl:template>
18-
19-
<xsl:template match="wix:Feature/@Title">
20-
<xsl:attribute name="Title">Svn2Git.NET.Main</xsl:attribute>
21-
</xsl:template>
22-
23-
<xsl:template match="wix:Product/wix:Directory/wix:Directory/@Id">
24-
<xsl:attribute name="Id">APPLICATIONROOTDIRECTORY</xsl:attribute>
25-
</xsl:template>
26-
27-
<xsl:template match="wix:Product/wix:Directory/wix:Directory/@Name">
28-
<xsl:attribute name="Name">Svn2Git.NET</xsl:attribute>
29-
</xsl:template>
30-
31-
<xsl:template match="wix:Product/wix:Directory/wix:Directory">
32-
<Directory Id="ProgramFilesFolder" xmlns="http://schemas.microsoft.com/wix/2006/wi">
33-
<xsl:copy>
34-
<xsl:apply-templates select="@*|node()" />
35-
</xsl:copy>
36-
</Directory>
37-
</xsl:template>
38-
39-
<xsl:template match="node() | @*">
40-
<xsl:copy>
41-
<xsl:apply-templates select="@* | node()"/>
42-
</xsl:copy>
43-
</xsl:template>
44-
1+
<xsl:transform version="1.0"
2+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3+
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
4+
5+
<xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>
6+
7+
<xsl:template match="wix:Product/@Version">
8+
<xsl:attribute name="Version">1.0.0.0</xsl:attribute>
9+
</xsl:template>
10+
11+
<xsl:template match="wix:Product/@Manufacturer">
12+
<xsl:attribute name="Manufacturer">Jingyu Ma</xsl:attribute>
13+
</xsl:template>
14+
15+
<xsl:template match="wix:Product/@Name">
16+
<xsl:attribute name="Name">Svn2Git.NET</xsl:attribute>
17+
</xsl:template>
18+
19+
<xsl:template match="wix:Feature/@Title">
20+
<xsl:attribute name="Title">Svn2Git.NET.Main</xsl:attribute>
21+
</xsl:template>
22+
23+
<xsl:template match="wix:Product/wix:Directory/wix:Directory/@Id">
24+
<xsl:attribute name="Id">APPLICATIONROOTDIRECTORY</xsl:attribute>
25+
</xsl:template>
26+
27+
<xsl:template match="wix:Product/wix:Directory/wix:Directory/@Name">
28+
<xsl:attribute name="Name">Svn2Git.NET</xsl:attribute>
29+
</xsl:template>
30+
31+
<xsl:template match="wix:Product/wix:Directory/wix:Directory">
32+
<Directory Id="ProgramFilesFolder" xmlns="http://schemas.microsoft.com/wix/2006/wi">
33+
<Component Id ="setEnviroment">
34+
<xsl:attribute name="Guid">{9AE672fD-224C-44D4-A38C-26012FF0B478}</xsl:attribute>
35+
<CreateFolder />
36+
<Environment
37+
Id="Environment"
38+
Name="PATH"
39+
Part="last"
40+
System="yes"
41+
Action="set"
42+
Value="[APPLICATIONROOTDIRECTORY]" />
43+
</Component>
44+
<xsl:copy>
45+
<xsl:apply-templates select="@*|node()" />
46+
</xsl:copy>
47+
</Directory>
48+
</xsl:template>
49+
50+
<xsl:template match="wix:Fragment/wix:ComponentGroup">
51+
<xsl:copy>
52+
<xsl:apply-templates select="@*|node()" />
53+
<ComponentRef Id="setEnviroment" xmlns="http://schemas.microsoft.com/wix/2006/wi" />
54+
</xsl:copy>
55+
</xsl:template>
56+
57+
<xsl:template match="node() | @*">
58+
<xsl:copy>
59+
<xsl:apply-templates select="@* | node()"/>
60+
</xsl:copy>
61+
</xsl:template>
62+
4563
</xsl:transform>

0 commit comments

Comments
 (0)