|
| 1 | +# _git_ SVN Sync |
| 2 | + |
| 3 | +This repository is intended to provide synchronization between a |
| 4 | +running SVN repository and _git_, so that we can get away from |
| 5 | +subversion while the build jobs are ported. |
| 6 | + |
| 7 | +## Workflow |
| 8 | + |
| 9 | +The idea is to use pure _git_ exclusively. The subversion repository is |
| 10 | +up to date and used to build artifacts and jars, but nobody is |
| 11 | +expected to write to it except the _git_ sync client. |
| 12 | + |
| 13 | +Therefore _git_ would be used both at client and server side. This is an |
| 14 | +improvement over using git-svn because it allows to commit branches to |
| 15 | +the server, and avoids rewriting history when commiting to svn, among |
| 16 | +other things. |
| 17 | + |
| 18 | +## Technical view |
| 19 | + |
| 20 | +For every project in subversion, two _git_ repositories are created, the |
| 21 | +server and the sync client. |
| 22 | + |
| 23 | +### _git_ Server |
| 24 | + |
| 25 | +It is a normal bare repository, which supports every git |
| 26 | +operation. Every developer clones this repository and uses it |
| 27 | +exclusively for the project. |
| 28 | + |
| 29 | +When someone pushes changes to the master branch, a hook is run which |
| 30 | +uses the sync client to bring the changes to subversion. |
| 31 | + |
| 32 | +### _git_ Sync client |
| 33 | + |
| 34 | +This is a repository which is a clone of the _git_ server. When the |
| 35 | +post-receive hook at the server is activated, the following happens at |
| 36 | +this client: |
| 37 | + |
| 38 | + * Changes are pulled from the server to the master branch. |
| 39 | + * The master branch is merged into a svn sync branch. |
| 40 | + * The changes are sent to subversion via git-svn. |
| 41 | + |
| 42 | +This repository is not intended for developers to use. It rejects |
| 43 | +every push and commit, and should only automatically sync with the |
| 44 | +server. |
| 45 | + |
| 46 | +### Maintaining consistency |
| 47 | + |
| 48 | +The _git_ server and subversion should be in the same state at every |
| 49 | +time. To guarantee this, the following conditions are required: |
| 50 | + |
| 51 | + * Only the _git_ sync client should ever send changes to |
| 52 | + subversion. The write access to svn should be restricted to the |
| 53 | + remote _git_ user. |
| 54 | + * Nobody except the build jobs in jenkins uses subversion directly |
| 55 | + anymore. Developers interact only with the _git_ server. |
| 56 | + * The _git_ sync client is never modified. It only pulls changes from |
| 57 | + the _git_ server (only fast-forward allowed). |
| 58 | + |
| 59 | +The consistency is assured via hooks that are installed at the server |
| 60 | +and sync client. Access to subversion has to be configured separately. |
| 61 | + |
| 62 | +### Reporting |
| 63 | + |
| 64 | +If something does not work correctly, a mail will be sent specifying |
| 65 | +the project which had the problem and the registered error |
| 66 | + |
| 67 | +## Setup |
| 68 | + |
| 69 | +### Initial setup |
| 70 | + |
| 71 | +The machine where the repositories are installed needs the following |
| 72 | +environment variables (defined in its ~/.bashrc): |
| 73 | + |
| 74 | + * **GIT_SCRIPTS**: directory where the _git_ sync scripts are located |
| 75 | + * **GIT_BASE**: directory where the _git_ repositories are stored. |
| 76 | + * **GIT_SVN_SYNC_BASE**: directory where the sync repositories are stored. |
| 77 | + * **GIT_SVN_SYNC_BRANCH**: name of the branch that is synchronized |
| 78 | + with subversion. |
| 79 | + |
| 80 | +This repository should be cloned in the directory **GIT_SCRIPTS**. |
| 81 | + |
| 82 | +### SVN User |
| 83 | + |
| 84 | +Git needs to have write access to subversion. |
| 85 | + |
| 86 | +### Git config |
| 87 | + |
| 88 | +For the git user that will sync with svn |
| 89 | + |
| 90 | + git config --global user.email "the@email" |
| 91 | + git config --global user.name "Git User" |
| 92 | + |
| 93 | +### New project |
| 94 | + |
| 95 | +Each project in subversion can be initialized with the |
| 96 | +install/git-repository-from-svn.sh script. It makes sure that the |
| 97 | +initial setup is carried and that the hooks are activated. |
| 98 | + |
| 99 | + |
0 commit comments