1
|
#!/bin/bash
|
2
|
|
3
|
# Script to convert MAUS branches to a git repository
|
4
|
# A. Dobbs, September 2015
|
5
|
# ---------------------------------------------------
|
6
|
|
7
|
BZR_REPO=/vols/fets2/adobbs/MAUS/maus/
|
8
|
GIT_REPO=${BZR_repo}/git-repo
|
9
|
|
10
|
clean-up-old-files () {
|
11
|
# Function to remove old files that conversion resurrects
|
12
|
cd ${GIT-REPO}
|
13
|
git rm -r components
|
14
|
git rm -r core
|
15
|
git rm -r src/reduce/ReducePyAcceleratorParameters/
|
16
|
git rm src/legacy/Config/BeamlineGeometry.cc
|
17
|
git rm src/legacy/Config/BeamlineGeometry.hh
|
18
|
git rm src/legacy/Config/BeamlineParameters.cc
|
19
|
git rm src/legacy/Config/BeamlineParameters.hh
|
20
|
git rm src/legacy/Config/RFBackgroundParameters.cc
|
21
|
git rm src/legacy/Config/RFBackgroundParameters.hh
|
22
|
git rm src/legacy/Interface/AnalysisPlaneBank.cc
|
23
|
git rm src/legacy/Interface/AnalysisPlaneBank.hh
|
24
|
git rm src/legacy/Interface/CppErrorHandler.cc
|
25
|
git rm src/legacy/Interface/CppErrorHandler.hh
|
26
|
git rm src/legacy/Interface/JsonWrapper.cc
|
27
|
git rm src/legacy/Interface/JsonWrapper.hh
|
28
|
git rm src/legacy/Simulation/MAUSGeant4Manager.cc
|
29
|
git rm src/legacy/Simulation/MAUSGeant4Manager.hh
|
30
|
git rm src/legacy/Simulation/MAUSPrimaryGeneratorAction.cc
|
31
|
git rm src/legacy/Simulation/MAUSPrimaryGeneratorAction.hh
|
32
|
git rm src/legacy/Simulation/MAUSSteppingAction.cc
|
33
|
git rm src/legacy/Simulation/MAUSSteppingAction.hh
|
34
|
git rm src/legacy/Simulation/MAUSTrackingAction.cc
|
35
|
git rm src/legacy/Simulation/MAUSTrackingAction.hh
|
36
|
git rm src/legacy/Simulation/MICEEventAction.cc
|
37
|
git rm src/legacy/Simulation/MICEEventAction.hh
|
38
|
git rm src/legacy/Simulation/MICEPrimaryGeneratorAction.hh
|
39
|
git rm src/legacy/Simulation/MICESteppingAction.cc
|
40
|
git rm src/legacy/Simulation/MICESteppingAction.hh
|
41
|
git rm src/legacy/Simulation/VirtualPlanes.cc
|
42
|
git rm src/legacy/Simulation/VirtualPlanes.hh
|
43
|
git rm tests/integration/00build_essential.bash
|
44
|
git rm tests/integration/01build_rest.bash
|
45
|
git rm tests/integration/02scons_configure_all.bash
|
46
|
git rm tests/integration/03build_commoncpp.bash
|
47
|
git rm tests/integration/04build_all.bash
|
48
|
git rm tests/integration/05unit.bash
|
49
|
}
|
50
|
|
51
|
configure-empty-folders () {
|
52
|
# Function to setup empty folders with a place holder file so git will accept them
|
53
|
cd ${GIT-REPO}
|
54
|
|
55
|
mkdir build
|
56
|
echo 'Git cannot handle empty folders, hence a place holder file.' > PlaceHolder.txt
|
57
|
mv PlaceHolder.txt build/
|
58
|
git add build/PlaceHolder.txt
|
59
|
|
60
|
mkdir tmp
|
61
|
cp build/PlaceHolder.txt tmp/
|
62
|
git add tmp/PlaceHolder.txt
|
63
|
|
64
|
mkdir tests/integration/plots/
|
65
|
cp build/PlaceHolder.txt tests/integration/plots/
|
66
|
git add tests/integration/plots/PlaceHolder.txt
|
67
|
|
68
|
mkdir tests/py_unit/test_geometry/testCases/testGDMLtoMAUSModule/
|
69
|
cp build/PlaceHolder.txt tests/py_unit/test_geometry/testCases/testGDMLtoMAUSModule/
|
70
|
git add tests/py_unit/test_geometry/testCases/testGDMLtoMAUSModule/PlaceHolder.txt
|
71
|
}
|
72
|
|
73
|
configure-merge-branch () {
|
74
|
# Function to merge changes in master branch to merge branch
|
75
|
cd ${GIT-REPO}
|
76
|
git checkout merge
|
77
|
git merge master
|
78
|
git checkout master
|
79
|
}
|
80
|
|
81
|
create-git-repo () {
|
82
|
# Function to create a git repository and import the MAUS branches
|
83
|
# Start from inside a MAUS shared repository containing the merge and release branches:
|
84
|
cd ${BZR_REPO}
|
85
|
mkdir git-repo
|
86
|
cd git-repo
|
87
|
git init
|
88
|
}
|
89
|
|
90
|
import-maus-branches () {
|
91
|
# Function to export maus branches and the import them to the git repo
|
92
|
cd ${GIT-REPO}
|
93
|
git checkout master
|
94
|
bzr fast-export --export-marks=../marks.bzr ../release | git fast-import --export-marks=../marks.git
|
95
|
bzr fast-export --marks=../marks.bzr --git-branch=merge ../merge | git fast-import --import-marks=../marks.git --export-marks=../marks.git
|
96
|
git reset --hard
|
97
|
}
|
98
|
|
99
|
purge-large-data () {
|
100
|
# Function to remove gdc1901.001 from all revisions, as it is too large for git hub
|
101
|
cd ${GIT-REPO}
|
102
|
git filter-branch --prune-empty -d /vols/fets2/adobbs/scratch --index-filter "git rm --cached -f --ignore-unmatch src/input/InputCppDAQData/gdc1901.001" --tag-name-filter cat -- --all
|
103
|
}
|
104
|
|
105
|
push-to-remote () {
|
106
|
# Function to push the branches to the mice-software repository on github
|
107
|
cd ${GIT-REPO}
|
108
|
git checkout master
|
109
|
git remote add origin git@github.com:mice-software/maus.git
|
110
|
git push -u origin master
|
111
|
git checkout merge
|
112
|
git push -u origin merge
|
113
|
}
|
114
|
|
115
|
# Main programme
|
116
|
# --------------
|
117
|
|
118
|
# echo 'Creating a git repository to store the MAUS branches'
|
119
|
create-git-repo
|
120
|
|
121
|
# echo 'Exporting bzr branches and import to git'
|
122
|
import-maus-branches
|
123
|
|
124
|
echo 'Configuring git repo to accept empty maus folders'
|
125
|
configure-empty-folders
|
126
|
|
127
|
echo 'Removing files and folders from previous MAUS revisions'
|
128
|
clean-up-old-files
|
129
|
|
130
|
# echo 'Purging files too large for github (>100MB)'
|
131
|
purge-large-data
|
132
|
|
133
|
# echo 'Building and testing MAUS'
|
134
|
./install_build_test.bash -j 8
|
135
|
|
136
|
# echo 'Commit the changes to the master'
|
137
|
git commit -m 'Conversion from Bzr to Git'
|
138
|
|
139
|
# echo 'Configuring merge branch'
|
140
|
configure-merge-branch
|
141
|
|
142
|
# echo 'Pushing branches to github'
|
143
|
# push-to-remote
|