forked from SchildiChat/schildichat-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge_helpers.sh
executable file
·118 lines (98 loc) · 3.16 KB
/
merge_helpers.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
SCHILDI_ROOT="$(dirname "$(realpath "$0")")"
i18n_helper_path="$SCHILDI_ROOT/i18n-helper/index.js"
i18n_path="src/i18n/strings"
i18n_overlay_path="$SCHILDI_ROOT/i18n-overlays"
add_upstream() {
if git remote | grep -q upstream; then
echo "Remote named upstream already exists!"
return 1
fi
local sc_remote="$(git remote -v|grep origin|grep fetch|sed 's|.*\t\(.*\) (fetch)|\1|')"
if echo "$sc_remote" | grep -q matrix; then
# matrix.org repo
local upstream_remote="$(echo "$sc_remote" | sed 's|SchildiChat|matrix-org|')"
elif echo "$sc_remote" | grep -q element; then
# vector-im repo
local upstream_remote="$(echo "$sc_remote" | sed 's|SchildiChat|vector-im|')"
else
echo "Don't know upstream repo for $sc_remote"
return 1
fi
echo "Adding upstream $upstream_remote"
git remote add upstream "$upstream_remote"
git fetch upstream
}
forall_repos() {
pushd "$SCHILDI_ROOT/matrix-js-sdk"
"$@"
popd
pushd "$SCHILDI_ROOT/matrix-react-sdk"
"$@"
popd
pushd "$SCHILDI_ROOT/element-web"
"$@"
popd
pushd "$SCHILDI_ROOT/element-desktop"
"$@"
popd
}
ensure_yes() {
read -e -p "$1 [y/N] " choice
if [[ "$choice" != [Yy]* ]]; then
exit 1
fi
}
check_branch() {
if [[ $(git branch --show-current) != "$1" ]]; then
repo_name=$(basename `git rev-parse --show-toplevel`)
ensure_yes "$repo_name not in branch $1. Continue?"
fi
}
check_clean_git() {
# Require clean git state
uncommitted=`git status --porcelain`
if [ ! -z "$uncommitted" ]; then
echo "Uncommitted changes are present, please commit first!"
exit 1
fi
}
revert_i18n_changes() {
local i18n_path="$1"
local skip_commit="$2"
git checkout upstream/master -- "$i18n_path"
if [[ "$skip_commit" != [Yy]* ]]; then
git commit -m "Automatic i18n reversion" || true
fi
}
apply_i18n_changes() {
local i18n_path="$1"
git add "$i18n_path"
git commit -m "Automatic i18n adjustment" || true
}
automatic_i18n_reversion() {
local skip_commit="$1"
pushd "$SCHILDI_ROOT/matrix-react-sdk" > /dev/null
revert_i18n_changes "$i18n_path" $skip_commit
popd > /dev/null
pushd "$SCHILDI_ROOT/element-web" > /dev/null
revert_i18n_changes "$i18n_path" $skip_commit
popd > /dev/null
pushd "$SCHILDI_ROOT/element-desktop" > /dev/null
revert_i18n_changes "$i18n_path" $skip_commit
popd > /dev/null
}
automatic_i18n_adjustment() {
node "$i18n_helper_path" "$SCHILDI_ROOT/matrix-react-sdk/$i18n_path" "$i18n_overlay_path/matrix-react-sdk"
pushd "$SCHILDI_ROOT/matrix-react-sdk" > /dev/null
apply_i18n_changes "$i18n_path"
popd > /dev/null
node "$i18n_helper_path" "$SCHILDI_ROOT/element-web/$i18n_path" "$i18n_overlay_path/element-web"
pushd "$SCHILDI_ROOT/element-web" > /dev/null
apply_i18n_changes "$i18n_path"
popd > /dev/null
node "$i18n_helper_path" "$SCHILDI_ROOT/element-desktop/$i18n_path" "$i18n_overlay_path/element-desktop"
pushd "$SCHILDI_ROOT/element-desktop" > /dev/null
apply_i18n_changes "$i18n_path"
popd > /dev/null
}