source: trunk/scripts/git-migration/git-migrate-fast.sh @ 2603

Last change on this file since 2603 was 2578, checked in by broder, 15 years ago

There is no master branch. There is only prod. And dev.

But definitely no master.

  • Property svn:executable set to *
File size: 3.2 KB
RevLine 
[1901]1#!/bin/bash
2set -e
3
[2353]4# Depends: python-yaml, python-mako
5# and svn-all-fast-export, which comes from git://repo.or.cz/svn-all-fast-export
[2357]6# (except you actually want git://andersk.mit.edu/svn-all-fast-export localtime)
[2353]7# and builds with `qmake && make` with
[2357]8#   Build-Depends: libqt4-dev, libsvn-dev
[2353]9
10# Usage: ./git-migrate-fast.sh [svn-uri]
11# Exports into new subdir ./git .
[1902]12SVN=${1:-/mit/xvm/svn}
13
[1901]14mako-render rules.mako > rules
15
16rm git -rf
17mkdir git
18cd git
19
20sed -n 's/^create repository // p' ../rules | while read repo; do
[2578]21    mkdir -p "$repo" && GIT_DIR="$repo" git init --bare && GIT_DIR="$repo" git symbolic-ref HEAD refs/heads/prod
[1901]22done
23
[1941]24svn-all-fast-export --identity-map ../authors ../rules "$SVN"
[1901]25
[2356]26pushd packages/invirt-dev.git
27GIT_COMMITTER_NAME='Eric Price' GIT_COMMITTER_EMAIL='ecprice@mit.edu' GIT_COMMITTER_DATE='1206829393 -0400' \
28    git tag -a sipb-xen-dev/13 sipb-xen-dev/14~2 -F - <<EOF
29Tag 13 of sipb-xen-dev
[1920]30
[2356]31svn path=/package_tags/sipb-xen-dev/13/; revision=316
32EOF
[2015]33popd
34
[1920]35pushd packages/invirt-remote.git
[2356]36echo $(git rev-parse 0.2.0^0 invirt-remote-server invirt-remote-host) >> info/grafts
[1920]37git filter-branch --tag-name-filter cat -- ^invirt-remote-server ^invirt-remote-host --all
38rm -rf info/grafts refs/original refs/heads/invirt-remote-server refs/heads/invirt-remote-host
39popd
40
41pushd packages/invirt-console.git
[2356]42echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-console-host) >> info/grafts
[1920]43git filter-branch --tag-name-filter cat -- ^0.2.0^ ^invirt-console-host --all
44rm -rf info/grafts refs/original refs/heads/invirt-console-host
45popd
46
47pushd packages/invirt-dns.git
48echo $(git rev-parse sipb-xen-dns/1~10 sipb-xen-dns/1~11 dns) >> info/grafts
49git filter-branch --tag-name-filter cat -- ^sipb-xen-dns/1~11 ^dns --all
50rm -rf info/grafts refs/original refs/heads/dns
51popd
52
[2236]53pushd packages/invirt-database.git
[2356]54echo $(git rev-parse invirt-database-server/0.0.1^0 0.0.1^) >> info/grafts
55echo $(git rev-parse 0.2.0^0 0.2.0^ invirt-database-server) >> info/grafts
[2236]56git filter-branch --tag-name-filter cat -- ^0.2.0^ --all
57rm -rf info/grafts refs/original refs/heads/invirt-database-server
[1956]58popd
59
[1922]60pushd packages/python-routefs.git
[1939]61git fetch -t git://github.com/ebroder/python-routefs.git
62git branch -f upstream 1.0.1
[2578]63git branch -f prod 1.0.1-1
[1922]64popd
65
[2578]66for r in $(ls packages); do
67    pushd "packages/$r"
68    git branch dev prod
69    popd
70done
71
[2576]72mkdir packages.git
73pushd packages.git
74git init --bare
[2578]75git symbolic-ref HEAD refs/heads/prod
[2576]76(
77    echo 'commit refs/heads/prod'
78    echo 'mark :1'
79    echo 'committer Invirt Git Import <invirt@mit.edu> now'
80    echo 'data <<EOF'
81    echo 'Initial superrepo creation.'
82    echo 'EOF'
83    for r in $(ls ../packages); do
84        pushd "../packages/$r" &>/dev/null
[2578]85        commit="$(git rev-parse refs/heads/prod)"
[2576]86        popd &>/dev/null
87
88        echo "M 160000 $commit ${r%.git}"
89    done
90
91    echo 'M 100644 inline .gitmodules'
92    echo 'data <<EOF'
93    for r in $(ls ../packages); do
94        r="${r%.git}"
95        printf '[submodule "%s"]\n' "$r"
96        printf '\tpath = %s\n' "$r"
[2577]97        printf '\turl = git://invirt.mit.edu/invirt/packages/%s.git\n' "$r"
[2576]98    done
99    echo 'EOF'
100
101    echo 'reset refs/heads/dev'
102    echo 'from :1'
103
104    echo 'reset HEAD'
105    echo 'from :1'
106) | git fast-import --date-format=now
107popd
108
[1920]109echo
110echo 'The Git migration was successful.'
Note: See TracBrowser for help on using the repository browser.