Skip to content

Instantly share code, notes, and snippets.

@tmaroschik
Last active December 16, 2015 05:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tmaroschik/6f1b36a71dbe0ab0e1f8 to your computer and use it in GitHub Desktop.
Save tmaroschik/6f1b36a71dbe0ab0e1f8 to your computer and use it in GitHub Desktop.
Submodule merge script
#!/bin/bash
# Use absolute path as argument
branches[0]='TYPO3_4-2'
branches[1]='TYPO3_4-3'
branches[2]='TYPO3_4-4'
branches[3]='TYPO3_4-5'
branches[4]='TYPO3_4-6'
branches[5]='TYPO3_4-7'
branches[6]='TYPO3_6-0'
branches[7]='TYPO3_6-1'
branches[8]='master'
submodules[0]='dbal version'
submodules[1]='dbal extbase fluid version'
submodules[2]='dbal extbase fluid version'
submodules[3]='dbal extbase fluid linkvalidator workspaces version'
submodules[4]='dbal extbase fluid linkvalidator workspaces version'
submodules[5]='dbal extbase fluid linkvalidator workspaces version'
submodules[6]='dbal extbase fluid linkvalidator workspaces version'
submodules[7]='dbal extbase fluid linkvalidator workspaces version'
submodules[8]='dbal extbase fluid linkvalidator workspaces version'
dbal[0]='DBAL_0-9'
dbal[1]='DBAL_1-0'
dbal[2]='DBAL_1-1'
dbal[3]='DBAL_1-2'
dbal[4]='DBAL_1-3'
dbal[5]='dbal_4-7'
dbal[6]='dbal_6-0'
dbal[7]='dbal_6-1'
dbal[8]='master'
extbase[0]='extbase_1-0'
extbase[1]='extbase_1-1'
extbase[2]='extbase_1-2'
extbase[3]='extbase_1-3'
extbase[4]='extbase_1-4'
extbase[5]='extbase_4-7'
extbase[6]='extbase_6-0'
extbase[7]='extbase_6-1'
extbase[8]='master'
fluid[0]='fluid_1-0'
fluid[1]='fluid_1-1'
fluid[2]='fluid_1-2'
fluid[3]='fluid_1-3'
fluid[4]='fluid_1-4'
fluid[5]='fluid_4-7'
fluid[6]='fluid_6-0'
fluid[7]='fluid_6-1'
fluid[8]='master'
linkvalidator[0]=''
linkvalidator[1]=''
linkvalidator[2]=''
linkvalidator[3]='TYPO3_4-5'
linkvalidator[4]='TYPO3_4-6'
linkvalidator[5]='linkvalidator_4-7'
linkvalidator[6]='linkvalidator_6-0'
linkvalidator[7]='linkvalidator_6-1'
linkvalidator[8]='master'
version[0]='4.2'
version[1]='4.3'
version[2]='4.4'
version[3]='4.5'
version[4]='4.6'
version[5]='version_4-7'
version[6]='version_6-0'
version[7]='version_6-1'
version[8]='master'
workspaces[0]=''
workspaces[1]=''
workspaces[2]=''
workspaces[3]='4.5'
workspaces[4]='4.6'
workspaces[5]='workspaces_4-7'
workspaces[6]='workspaces_6-0'
workspaces[7]='workspaces_6-1'
workspaces[8]='master'
mkdir -p $1
cd $1
git clone git://git.typo3.org/TYPO3v4/Extensions/dbal.git
git clone git://git.typo3.org/TYPO3v4/CoreProjects/MVC/extbase.git
git clone git://git.typo3.org/TYPO3v4/CoreProjects/MVC/fluid.git
git clone git://git.typo3.org/TYPO3v4/Extensions/linkvalidator.git
git clone git://git.typo3.org/TYPO3v4/CoreProjects/workspaces/workspaces.git
git clone git://git.typo3.org/TYPO3v4/CoreProjects/workspaces/version.git
for submodule in dbal extbase fluid linkvalidator workspaces version
do
cd $submodule
git fetch origin refs/heads/sandbox/tmaroschik/ns-change-history-repair
branchVarKey=${submodule}[@]
for branch in ${!branchVarKey}
do
git branch --track $branch remotes/origin/${branch##*/} 2>&1 || true
done
git fetch --all
git pull --all
cd $1
done
cd dbal
git replace c9d30784461508b489c54693e19089b4622c7efe d0a16135d9c7e9115c7d2d55c4acf2512d42d1d0
cd $1
cd extbase
git replace 569063f64331766ea780cd118f0fd6c707664c16 156a292f9b5726b93bfeec72392c1ad79ed0fd28
cd $1
cd fluid
git replace b61c0d793f7d77a4fbb4c0f0de1b019c57ac3cb6 b46eda4184241b542e1f2157e347c8ab6cbc36fd
cd $1
cd linkvalidator
git replace 01c33b1e11c58bdd9242de791b5d75496408b23a 51b7ec4a8969d3542ff21d6260449a6ce6601f6d
cd $1
cd version
git replace 1c618876ef21c15c8197bbdc0c9e874460330bcc fce1007b74a947da24c257601bff9b63001f64fc
cd $1
cd workspaces
git replace f41abc25dfddff82fa893f7a8f92fee931b89df9 69e5d2421b8106bf2420b1518ac6f1907df394f2
cd $1
for submodule in dbal extbase fluid linkvalidator workspaces version
do
cd $submodule
command=$(printf "if [ ! -e typo3/sysext/%s ]; then mkdir -p typo3/sysext/%s; git ls-tree --name-only \${GIT_COMMIT} | grep -v ^typo3$ | xargs -I files mv files typo3/sysext/%s || echo ''; fi" $submodule $submodule $submodule)
git filter-branch --prune-empty --tree-filter "$command" --tag-name-filter cat -- --all
git gc --aggressive
cd $1
done
git clone git://git.typo3.org/TYPO3v4/Core.git
cd Core
for submodule in dbal extbase fluid linkvalidator workspaces version
do
git remote add -f $submodule ../$submodule
done
for branchIndex in ${!branches[*]}
do
coreBranch=${branches[$branchIndex]}
git checkout -b $coreBranch origin/$coreBranch 2>&1 || git checkout $coreBranch
for submodule in ${submodules[$branchIndex]}
do
rm -R typo3/sysext/$submodule && git checkout typo3/sysext/$submodule
done
for submodule in ${submodules[$branchIndex]}
do
branchVarKey=${submodule}[${branchIndex}]
submoduleBranch=${!branchVarKey}
git merge $submodule/$submoduleBranch 2>&1 || true
git rm --cached typo3/sysext/$submodule
git config -f .gitmodules --remove-section "submodule.typo3/sysext/$submodule"
git add .gitmodules
git commit -m "[TASK] Merge submodule $submodule into core"
done
done
git gc --aggressive
#git fetch origin refs/heads/sandbox/tmaroschik/ns-change-history-repair
#git replace 4612259a457f43edaf723e1f4a8ef4ae89d00a34 62006c8b36aedd2ae7d8eef9712ec34afdafb164
#git filter-branch
@andreaswolf
Copy link

I think there's a tiny error in this script: line 26 should say "git remote add $submodule ../$submodule" (not "add dbal ..."), otherwise the next step will fail for all submodules except dbal.

@tmaroschik
Copy link
Author

Updated

@tmaroschik
Copy link
Author

Updated to merge modules also into branches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment