Giter VIP home page Giter VIP logo

git-svn-push's Introduction

****************************************************************************
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.  This defaults to
    "/export/home/javadev/gitsync" for historical reasons.


# 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:

        $ 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

git-svn-push's People

Contributors

martinlong1978 avatar wmanley avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.