-
Notifications
You must be signed in to change notification settings - Fork 24
/
rc-migration.sh
76 lines (56 loc) · 1.67 KB
/
rc-migration.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
### Argument check ###
if [[ $# -eq 0 ]] ; then
echo '✗ Please supply a Git repository path as an argument!'
echo 'Example:'
echo './rc-migration.sh ~/projects/MyProject'
echo 'Example for Windows, in a Git bash:'
echo './rc-migration.sh /c/projects/MyProject'
exit 1
fi
repo=$1
echo "✓ Migrating repository at path $repo to RainbowCake 0.2.0"
### Change directory ###
cd "$repo"
if [[ $? -eq 0 ]]; then
echo '✓ Found directory at the given path'
else
echo "✗ Can't find the specified directory."
exit 1
fi
### Git repository checks ###
if [[ -d .git ]]; then
echo '✓ Found .git folder'
else
echo "✗ Can't find Git repository!"
exit 1
fi;
if ! git ls-files >& /dev/null; then
echo '✗ Supplied path is not a Git repository'
exit 1
else
echo '✓ Git repository looks OK'
fi
### Git status check ###
test -z "$(git status --porcelain)"
if [[ $? -eq 0 ]]; then
echo "✓ No untracked files in repository directory"
else
echo '✗ You have untracked or uncommitted files in your repository directory!'
echo '✗ Here they are:'
git status --porcelain
exit 1
fi
### Migration ###
echo '✓ Performing migration, just a moment...'
git ls-files *.kt | xargs sed -b -i \
-e 's/hu\.autsoft\.rainbowcake/co\.zsmb\.rainbowcake/g' \
-e 's/BaseViewModel/RainbowCakeViewModel/g' \
-e 's/BaseFragment/RainbowCakeFragment/g' \
-e 's/BaseActivity/RainbowCakeActivity/g' \
-e 's/BaseApplication/RainbowCakeApplication/g' \
-e 's/BaseModule/RainbowCakeModule/g' \
-e 's/BaseComponent/RainbowCakeComponent/g'
### Epilogue ###
echo '✓ Migration done! Here are the files changed:'
git ls-files -m
echo '✓ Done.'