forked from ansible/ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unify_repos.sh
executable file
·56 lines (48 loc) · 1.55 KB
/
unify_repos.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
set -x
set -e
set -u
# get current stuff
git clone [email protected]:ansible/ansible.git ansible_unified
cd ansible_unified/
git submodule init
git submodule update
# add submodules as remotes
git remote add core_modules [email protected]:ansible/ansible-modules-core.git
git remote add extras_modules [email protected]:ansible/ansible-modules-extras.git
git fetch --all
# remove submodules
echo "" > .gitmodules
git add .gitmodules
git rm --cached lib/ansible/modules/core/
git rm --cached lib/ansible/modules/extras/
git commit -am "removed core and extras submodules"
rm -rf lib/ansible/modules/core
rm -rf lib/ansible/modules/extras
# merge remotes into old submodule dirs
## core
git merge -s ours --allow-unrelated-histories --no-commit core_modules/devel
git read-tree --prefix=lib/ansible/modules/core -u core_modules/devel
git commit -am 'core modules back to main repo'
## extras
git merge -s ours --allow-unrelated-histories --no-commit extras_modules/devel
git read-tree --prefix=lib/ansible/modules/extras -u extras_modules/devel
git commit -am 'extras modules back to main repo'
for subdir in core extras
do
# unify directories
for mydir in $(find lib/ansible/modules/${subdir} -type d)
do
mkdir -p ${mydir/$subdir\//}
done
# move plugins
for myfile in $(find lib/ansible/modules/${subdir} -type f)
do
if [ -e ${myfile/$subdir\///} ]; then #mostly to avoid __init__.py clobering
echo "skipping ${myfile} as it already exists in destination"
else
git mv ${myfile} ${myfile/$subdir\//}
fi
done
git rm -rf lib/ansible/modules/${subdir}
done