forked from martinlong1978/Git-Svn-push
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
103 lines (70 loc) · 3.51 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
****************************************************************************
IMPORTANT Version 2.0 is not backwards compatible with version 1.0. You will
need to make configuration file changes, and possibly rebuild the map
file manually.
****************************************************************************
This is a simple one-way GIT to SVN sync. It will push up your GIT branches to
a central SVN server. You should lock down the SVN server so that only a single
user can commit - the one which is running GitSvnPush, otherwise any commits
made by other people will be reverted (effectively overwritten) by the script.
It will push up all of your branches, finding, where possible, the correct
branch point. It does not write any mergeinfo - that should never be needed if
the SVN repo remains read-only.
Still needs tidying up. I'd like to try and figure out someday how to make this
work without SVN working copies, and maybe ever with a bare GIT repo.
# Usage
svnExport.pl [GIT-SVN-push-root]
GIT-SVN-push-root is a directory which should be created as per the
"Installation" section below.
# Installation
1. Create a directory within which all the work will be done:
$ mkdir -p /export/git-svn-push
2. Modify svnExport.pl to point at that directory by editing line 22 to say or parse it as first argument:
$ my $SYNC_BASE="/export/git-svn-push";
3. Create additional directories:
$ mkdir -p /export/git-svn-push/workingdata;
$ mkdir -p /export/git-svn-push/workingdata/messages;
4. Clone your git repo into `/export/git-svn-push/GIT/project-name`
$ git clone git://example.com/project-name.git /export/git-svn-push/GIT/project-name
5. Create a configuration file for your project in
`/export/git-svn-push/GIT/project-name.config` (see Configuration below)
And you're good to go.
# Configuration
Per project configuration must be added:
project.config
Has the format:
# Comments
key=value
Required fields:
SVN_URL=https://example.com/example-repo
Optional fields:
BRANCH_ORDER=branch1,branch2,branch3
SVN_FETCH=trunk:refs/remotes/origin/master
SVN_BRANCHES=branches/*:refs/remotes/origin/*
In this case the SVN URL for trunk is
https://example.com/example-repo/trunk and the branches are according
to the glob https://example.com/example-repo/branches/* . This
differs from the std-layout that git svn expects. SVN_FETCH defaults
to trunk and SVN_BRANCHES to (the non-standard) "branches/*/trunk".
This behaviour is preserved for backwards compatibility.
project.lock
# How it works
A mapping between svn and git commits is kept in
/export/git-svn-push/workingdata/$project.revcache It takes the form:
[svn revision] [branch name] [git commit sha]
Example:
1234 foo 0123456789ABCDEF0123456789ABCDEF01234567
1235 trunk ABCDEF012345670123456789ABCDEF0123456789
This allows us to map from svn revision to git commits
A git tag is kept at refs/tags/svnbranch/[branch name] so we can tell when it
has moved on and which commits have been made to git that are not yet in svn.
When a new branch is discovered we look back in the history to find a git commit
for which we have an svn commit and `svn cp` from there
# TODO
* Do things on a commit-by-commit basis rather than branch-by-branch
* Commit to branch that first parent is on if we are still on that git
branch, otherwise commit to new branch
* Store full svn url in rev map
* Sync tags
* Use `mktemp -d` for creating temporary directories
* Write automated tests