-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathupdate_repos.sh
executable file
·256 lines (230 loc) · 8.02 KB
/
update_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
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
#!/bin/sh
# Directory of the license-changer repository
CHANGER_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# This changes license in every file and commits the changes
change_license () {
TEMPDIR=$1 repo=$2
for file in $(git ls-files)
do
if [[ $repo == invenio* ]]; then
$CHANGER_DIR/change_license.py $file &> /dev/null
else
# Pass repository name as second parameter (license formatting)
# if it's not invenio-*
$CHANGER_DIR/change_license.py $file $repo &> /dev/null
fi
done
git commit -a -m 'global: license change and files cleanup' --author='Invenio <[email protected]>' --no-gpg-sign &> /dev/null
$CHANGER_DIR/clean_files.py setup.py &> /dev/null
git commit -a -m 'installation: removed pytest-cache dependency' --author='Invenio <[email protected]>' --no-gpg-sign &> /dev/null
$CHANGER_DIR/update_travis.py .travis.yml
git commit -a -m 'global: add allow_failures to travis config' --author='Invenio <[email protected]>' --no-gpg-sign &> /dev/null
git grep -n "distributed in the hope that" | cat
git grep -n "GPL" | cat
}
# This deletes files passed as argument and commits the changes
delete_files () {
num_of_files_deleted=0
declare -a files=("$@")
for file in "${files[@]}";
do
if [ -f $file ]; then
rm $file
num_of_files_deleted=$((num_of_files_deleted + 1))
fi
done
if [ $num_of_files_deleted -gt 0 ]; then
git commit -a -m 'global: remove unused files' --author='Invenio <[email protected]>' --no-gpg-sign &> /dev/null
else
echo "No files to delete in this repository"
fi
}
# This edits the CHANGES.rst file adding only the release 1.0.0
edit_changes_file () {
# Returns 1 or 2 if files differ or CHANGES.rst doesn't exist
if diff $CHANGER_DIR/templates/changes_template.rst CHANGES.rst &> /dev/null; then
cp $CHANGER_DIR/templates/changes_template.rst CHANGES.rst
git add CHANGES.rst
git commit -a -m 'global: prepared CHANGES.rst file for initial release' --author='Invenio <[email protected]>' --no-gpg-sign &> /dev/null
else
echo "CHANGES.rst file is up to date. No changes made"
fi
}
# This copies the CONTRIBUTING.rst file from invenio to every repo from inveniosoftware
update_contributing_file () {
cp $CHANGER_DIR/templates/contributing_template.rst CONTRIBUTING.rst
git add CONTRIBUTING.rst
git commit -a -m 'global: harmonize contributing guidelines' --author='Invenio <[email protected]>' --no-gpg-sign &> /dev/null
}
main () {
# This creates a directory in $HOME/$TEMPDIR (see below)
TEMPDIR="tmpsrc"
if [ ! -d "$HOME/$TEMPDIR" ]; then
mkdir $HOME/$TEMPDIR
fi
declare -a repos=(
### Initial repositories on the list stuff
#"dcxml"
#"citeproc-py-styles"
#"invenio-marc21"
#"invenio-theme"
#"invenio-search-js"
#"invenio-search-ui"
#"invenio-search"
#"invenio-rest"
#"invenio-records-ui"
#"invenio-records"
#"invenio-pidstore"
#"invenio-oauthclient"
#"invenio-oauth2server"
#"invenio-logging"
#"invenio-formatter"
#"invenio-db"
#"invenio-config"
#"invenio-celery"
#"invenio-cache"
#"invenio-base"
#"invenio-assets"
#"invenio-app"
#"invenio-admin"
#"invenio-accounts"
#"invenio-access"
#"invenio-userprofiles"
#"invenio-records-rest"
#"invenio-oaiserver"
#"invenio-mail"
#"invenio-jsonschemas"
#"invenio-indexer"
#"invenio-i18n"
# New repos (We don't run it for those)
#### "pytest-invenio"
#### "dojson"
#### "Flask-Menu"
#### "datacite"
#### "jsonresolver"
#### "Flask-Breadcrumbs"
# Split by batches, uncomment batch by batch
## Batch 1
#"dcxml"
#"invenio-search-js"
#"invenio-cache"
#"invenio-config"
#"invenio-celery"
#"invenio-i18n"
#"invenio-db"
#"invenio-search"
#"invenio-mail"
#"invenio-assets"
#"invenio-formatter"
#"invenio-logging"
#"invenio-rest"
#"citeproc-py-styles"
###"Flask-Menu"
###"jsonresolver"
###"dojson"
###"datacite"
## Batch 2
#"invenio-base"
#"invenio-admin"
#"invenio-jsonschemas"
###"pytest-invenio"
###"Flask-Breadcrumbs"
## Batch 3
#"invenio-app"
#"invenio-accounts"
#"invenio-theme"
#"invenio-records"
## Batch 4
#"invenio-access"
#"invenio-oauth2server"
#"invenio-userprofiles"
#"invenio-search-ui"
##Batch 5
#"invenio-oauthclient"
#"invenio-pidstore"
## Batch 6
#"invenio-indexer"
#"invenio-records-ui"
## Batch 7
#"invenio-records-rest"
## Batch 8
#"invenio-marc21"
## Batch 9
#"invenio-oaiserver"
)
declare -a delfiles=(
.lgtm
MAINTAINERS
)
declare -a delfilesinvenio=(
RELEASE-NOTES.rst
)
declare -a keepreleasenotes=(
"dcxml"
"citeproc-py-styles"
"invenio-search-js"
)
for repo in "${repos[@]}"
do
if [ ! -d "$HOME/$TEMPDIR/$repo" ]; then
echo $repo "FETCHING"
cd "$HOME/$TEMPDIR"
git clone "[email protected]:inveniosoftware/${repo}.git" &> /dev/null
cd $repo
git remote rename origin upstream &> /dev/null
fi
cd "$HOME/$TEMPDIR/$repo"
git checkout -b release-1.0.0 &> /dev/null
change_license $TEMPDIR $repo
delete_files "${delfiles[@]}"
# Delete and sync release notes, but exclude some repositories
del_rel_notes=1
for repo2 in "${keepreleasenotes[@]}"
do
if [[ $repo == $repo2 ]]; then
del_rel_notes=0
break
fi
done
if [ $del_rel_notes -gt 0 ]; then
delete_files "${delfilesinvenio[@]}"
edit_changes_file $repo
echo "Updated release notes and changes file" $repo
fi
# Update AUTHORS.rst file
if [[ $repo == invenio* ]]; then
$CHANGER_DIR/update_contributors.py $HOME/$TEMPDIR/$repo
else
# Pass repository name as second parameter (license formatting)
# if it's not invenio-*
$CHANGER_DIR/update_contributors.py $HOME/$TEMPDIR/$repo $repo
fi
git commit -a -m 'global: Updated AUTHORS.rst' --author='Invenio <[email protected]>' --no-gpg-sign &> /dev/null
if [[ $repo == invenio* ]]; then
$CHANGER_DIR/change_license.py `find . -name 'version.py'` --versionbump=1 &> /dev/null
else
# Pass repository name as second parameter (license formatting)
# if it's not invenio-*
$CHANGER_DIR/change_license.py `find . -name 'version.py'` $repo --versionbump=1 &> /dev/null
fi
git commit -a -m 'release: v1.0.0' --author='Invenio <[email protected]>' --no-gpg-sign &> /dev/null
if [ -f "$HOME/$TEMPDIR/$repo/README.rst" ]; then
python $CHANGER_DIR/add_license_badge.py $HOME/$TEMPDIR/$repo/README.rst
else
echo "There's no README.rst Skipping" $repo
fi
## NOTE: Uncomment to inspect all changes
# git diff
git commit -a -m 'global: Added shield badge' --author='Invenio <[email protected]>' --no-gpg-sign &> /dev/null
# TODO: Contributing guide temporarily disabled
# update_contributing_file
# TODO: uncomment for actual live run
# git push upstream release-1.0.0 --force
done
for repo in "${repos[@]}"
do
echo "https://github.com/inveniosoftware/$repo/compare/master...release-1.0.0"
done
echo "All repos UPDATED"
}
main