Debian Codegraph @

extensions/VisualEditor/bin/updateSubmodule.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`. -eu
2
3 # This script generates a commit that updates the lib/ve submodule
4 # ./bin/updateSubmodule.sh updates to master
5 # ./bin/updateSubmodule.sh hash updates to specified hash
6
7 # cd to the VisualEditor directory
8 cd $(cd $(dirnamescip-shell system . . dirname. $0)/..; pwdscip-shell system . . pwd.)
9
10 # Check that both working directories are clean
11 if gitscip-shell system . . git. status -uno --ignore-submodules | grepscip-shell system . . grep. -i changes > /dev/nullscip-shell filesystem . . `/dev/null`.
12 then
13 echoscip-shell system . . echo. >&2 "Working directory must be clean"
14 exit 1
15 fi
16 cd lib/ve
17 if gitscip-shell system . . git. status -uno --ignore-submodules | grepscip-shell system . . grep. -i changes > /dev/nullscip-shell filesystem . . `/dev/null`.
18 then
19 echoscip-shell system . . echo. >&2 "lib/ve working directory must be clean"
20 exit 1
21 fi
22 cd ../..
23
24 # Use 'gerrit' if it exists, otherwise 'origin'
25 MW_REMOTE=$(gitscip-shell system . . git. remote | grepscip-shell system . . grep. -w gerrit || echoscip-shell system . . echo. origin)
26
27 gitscip-shell system . . git. fetch $MW_REMOTE
28 # Create sync-repos branch if needed and reset it to master
29 gitscip-shell system . . git. checkout -B sync-repos $MW_REMOTE/master
30 gitscip-shell system . . git. submodule update
31 cd lib/ve
32
33 CORE_REMOTE=$(gitscip-shell system . . git. remote | grepscip-shell system . . grep. -w gerrit || echoscip-shell system . . echo. origin)
34
35 gitscip-shell system . . git. fetch $CORE_REMOTE
36
37 # Figure out what to set the submodule to
38 if [scip-shell system . . `[`. -n "${1:-}" ]
39 then
40 TARGET="$1"
41 TARGETDESC="$1"
42 else
43 TARGET=$CORE_REMOTE/master
44 TARGETDESC="master ($(gitscip-shell system . . git. rev-parse --short $CORE_REMOTE/master))"
45 fi
46
47 # Generate commit summary
48 NEWCHANGES=$(gitscip-shell system . . git. log ..$TARGET --oneline --no-merges --topo-order --reverse --color=never)
49 TASKS=$(gitscip-shell system . . git. log ..$TARGET --no-merges --format=format:%B | grepscip-shell system . . grep. "Bug: T" | sortscip-shell system . . sort. | uniqscip-shell system . . uniq.)
50
51 # Ensure script continues if grep "fails" (returns nothing) with || : (due to -e flag in bash)
52
53 # Addede/removed i18n keys
54 ADDED_I18N_KEYS=$(gitscip-shell system . . git. diff HEAD..$TARGET -- i18n/en.json | grepscip-shell system . . grep. -E '^\+' | grepscip-shell system . . grep. --color=never -vE '^\+\+\+' | sedscip-shell system . . sed. -E 's/^\+\s*"([^"]+)":.*/\1/' | sedscip-shell system . . sed. 's/^/- /' || :)
55 DELETED_I18N_KEYS=$(gitscip-shell system . . git. diff HEAD..$TARGET -- i18n/en.json | grepscip-shell system . . grep. -E '^\-' | grepscip-shell system . . grep. --color=never -vE '^\-\-\-' | sedscip-shell system . . sed. -E 's/^\-\s*"([^"]+)":.*/\1/' | sedscip-shell system . . sed. 's/^/- /' || :)
56 # Find common keys (modified keys)
57 MODIFIED_KEYS=$(echoscip-shell system . . echo. -e "$ADDED_I18N_KEYS\n$DELETED_I18N_KEYS" | sortscip-shell system . . sort. | uniqscip-shell system . . uniq. -d)
58 # Remove modified keys from the added and removed lists
59 ADDED_I18N_KEYS=$(echoscip-shell system . . echo. "$ADDED_I18N_KEYS" | grepscip-shell system . . grep. -vxF -f <(echoscip-shell system . . echo. "$MODIFIED_KEYS") | sedscip-shell system . . sed. 's/^/- /')
60 DELETED_I18N_KEYS=$(echoscip-shell system . . echo. "$DELETED_I18N_KEYS" | grepscip-shell system . . grep. -vxF -f <(echoscip-shell system . . echo. "$MODIFIED_KEYS") | sedscip-shell system . . sed. 's/^/- /')
61
62 # Added/removed files
63 ADDED_FILES=$(gitscip-shell system . . git. diff HEAD..$TARGET --name-only --diff-filter=A | grepscip-shell system . . grep. --color=never -E "\.(js|css|less)$" | sedscip-shell system . . sed. 's/^/- /' || :)
64 DELETED_FILES=$(gitscip-shell system . . git. diff HEAD..$TARGET --name-only --diff-filter=D | grepscip-shell system . . grep. --color=never -E "\.(js|css|less)$" | sedscip-shell system . . sed. 's/^/- /' || :)
65
66 COMMITMSG="Update VE core submodule to $TARGETDESC
67
68 New changes:
69 $NEWCHANGES"
70
71 if [scip-shell system . . `[`. -n "$ADDED_I18N_KEYS" ]; then
72 COMMITMSG+="
73
74 Added i18n keys:
75 $ADDED_I18N_KEYS"
76 fi
77
78 if [scip-shell system . . `[`. -n "$DELETED_I18N_KEYS" ]; then
79 COMMITMSG+="
80
81 Deleted i18n keys:
82 $DELETED_I18N_KEYS"
83 fi
84
85 if [scip-shell system . . `[`. -n "$ADDED_FILES" ]; then
86 COMMITMSG+="
87
88 Added files:
89 $ADDED_FILES"
90 fi
91
92 if [scip-shell system . . `[`. -n "$DELETED_FILES" ]; then
93 COMMITMSG+="
94
95 Deleted files:
96 $DELETED_FILES"
97 fi
98
99 COMMITMSG+="
100
101 $TASKS"
102
103 # Check out master of VE core
104 gitscip-shell system . . git. checkout $TARGET
105
106 # Commit
107 cd ../..
108 gitscip-shell system . . git. commit lib/ve -m "$COMMITMSG" > /dev/nullscip-shell filesystem . . `/dev/null`.
109 if [scip-shell system . . `[`. "$?" == "1" ]
110 then
111 echoscip-shell system . . echo. >&2 "No changes"
112 else
113 catscip-shell system . . cat. >&2 <<END
114
115
116 Created commit:
117
118 $COMMITMSG
119 END
120 fi