-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrate-module
executable file
·89 lines (63 loc) · 2.01 KB
/
migrate-module
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# This scripts migrates an existing repository onto the osiota template
# repository.
SCRIPTPATH="$(readlink -f 2>/dev/null || perl -MCwd -e 'print Cwd::abs_path shift' $0)"
SCRIPTDIR="$(dirname "${SCRIPTPATH}")"
## Parse the arguments:
export REPO="$1"
export NEWNAME="$2"
if test "x$1" = "x"
then
echo "Usage: prog REPOURL [NEWNAME]"
exit 2
fi
if test "x${NEWNAME}" = "x"
then
NEWNAME="osiota-app-$(basename "${REPO}" ".git" | sed -e "s/^er-app-//" | sed -e "s/^osiota-app-//")"
fi
echo "APP: ${NEWNAME}"
# Clone the old repository:
git clone "${REPO}" "${NEWNAME}"
cd "${NEWNAME}/"
## Exec Plugin script:
PLUGINSCRIPT="${SCRIPTDIR}/migrate-plugin.sh"
if test -x "${PLUGINSCRIPT}"
then
"${PLUGINSCRIPT}"
fi
## Change commiter email and name (disabled):
NEW_NAME="$(git config user.name)"
NEW_EMAIL="$(git config user.email)"
if false
then
git filter-branch --env-filter "
if [ \"\$GIT_COMMITTER_EMAIL\" = '$NEW_EMAIL' ]
then
export GIT_COMMITTER_NAME='$NEW_NAME'
export GIT_COMMITTER_EMAIL='$NEW_EMAIL'
fi
if [ \"\$GIT_AUTHOR_EMAIL\" = '$NEW_EMAIL' ]
then
export GIT_AUTHOR_NAME='$NEW_NAME'
export GIT_AUTHOR_EMAIL='$NEW_EMAIL'
fi
" --tag-name-filter cat -- --branches --tags
fi
## Remove old files from history:
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch .gitignore LICENSE .editorconfig' --prune-empty --tag-name-filter cat -- --branches --tags
## List all authors:
echo "AUTHORS:"
git log --format='%aN <%aE>' | awk '{arr[$0]++} END{for (i in arr){print arr[i], i;}}' | sort -rn | cut -d\ -f2-
echo
echo "Have you asked all other authors, that you want to publish this repo?"
echo "Continue? [else hit Ctrl + C]"
read CONT
## Rebase the commits onto the template repository:
git remote remove origin
git remote add upstream git@github.com:osiota/base-repo-osiota-app.git
git fetch upstream
git rebase --onto upstream/master --root master
git remote remove upstream
rm -Rf .git/refs/original/
## Adapt package and schema files:
"${SCRIPTDIR}/adapt-package-and-schema"