-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsync.sh
More file actions
executable file
·185 lines (165 loc) · 4.08 KB
/
sync.sh
File metadata and controls
executable file
·185 lines (165 loc) · 4.08 KB
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
#!/bin/bash
# Copyright © Michal Čihař <michal@weblate.org>
#
# SPDX-License-Identifier: CC0-1.0
set -u -e
REPOS="
customize-example
wlc
scripts
weblate
website
weblate_schemas
translation-finder
munin
fail2ban
docker
docker-base
docker-dev
docker-compose
hosted wllegal
language-data
graphics
helm
fonts
siphashc
openshift
kotlin-sdk
unicode-segmentation-rs
.github
"
# Copy the files to all repos if not present, these are expected to diverge
INITFILES="
.pre-commit-config.yaml
.github/renovate.json
"
# Copy these files unconditionally
COPYFILES="
.github/workflows/pre-commit.yml
.github/workflows/pull_requests.yaml
.github/workflows/dependency-review.yml
.github/FUNDING.yml
.yamllint.yml
.editorconfig
SECURITY.md
.github/PULL_REQUEST_TEMPLATE.md
.markdownlint.yml
.github/ISSUE_TEMPLATE/bug_report.yml
.github/ISSUE_TEMPLATE/feature_request.yml
"
# Update these files if present
PRESENTFILES="
.github/workflows/closing.yml
.github/workflows/stale.yml
.github/workflows/labels.yml
.github/matchers/sphinx-linkcheck.json
.github/matchers/sphinx-linkcheck-warn.json
.github/matchers/sphinx.json
.github/matchers/mypy.json
.github/release.yml
.eslintrc.yml
.stylelintrc
"
# Files to remove
REMOVEFILES="
.markdownlint.json
.github/stale.yml
.github/matchers/flake8.json
.github/matchers/eslint-compact.json
.github/matchers/flake8.json.license
.github/matchers/eslint-compact.json.license
.github/workflows/flake8.yml
.github/ISSUE_TEMPLATE/bug_report.md
.github/ISSUE_TEMPLATE/feature_request.md
.github/ISSUE_TEMPLATE/support_question.md
.github/ISSUE_TEMPLATE/support_question.yml
.github/.kodiak.toml
.github/workflows/ruff.yml
.github/workflows/eslint.yml
.github/workflows/stylelint.yml
.github/workflows/codeql-analysis.yml
.eslintrc.yml
.github/labels.yml
.github/workflows/label-sync.yml
"
if [ ! -f .venv/bin/activate ]; then
echo "Missing virtualenv in .venv!"
exit 1
fi
# shellcheck disable=SC1091
. .venv/bin/activate
export ROOT="$PWD"
mkdir -p repos
cd repos
copyfile() {
file=$1
repo=$2
dir=$(dirname "$file")
if [ ! -d "$dir" ]; then
mkdir -p "$dir"
fi
if [ -f "../../${file%.*}.$repo.${file##*.}" ]; then
cp "../../${file%.*}.$repo.${file##*.}" "$file"
elif [ -f "../../$file.$repo" ]; then
cp "../../$file.$repo" "$file"
else
cp "../../$file" "$file"
fi
if [ -f "../../$file.license" ]; then
cp "../../$file.license" "$file.license"
elif [ -f "$file.license" ]; then
rm "$file.license"
fi
}
for repo in $REPOS; do
if [ ! -d "$repo" ]; then
git clone "git@github.com:WeblateOrg/$repo.git"
cd "$repo"
else
cd "$repo"
git reset --quiet --hard origin/HEAD
git remote prune origin
git pull --quiet
fi
echo "== $repo =="
# Check README
if ! grep -q Logo-Darktext-borders.png README.* 2> /dev/null; then
echo "WARNING: README does not containing logo."
fi
# Update files
mkdir -p .github/workflows/
for file in $INITFILES; do
if [ ! -f "$file" ]; then
copyfile "$file" "$repo"
fi
done
for file in $COPYFILES; do
copyfile "$file" "$repo"
done
for file in $PRESENTFILES; do
if [ -f "$file" ]; then
copyfile "$file" "$repo"
fi
done
for file in $REMOVEFILES; do
if [ -f "$file" ]; then
rm "$file"
fi
done
# Configure GitHub release notes generating
if grep -q generateReleaseNotes .github/workflows/*; then
copyfile ".github/release.yml" "$repo"
fi
# Apply fixes
"$ROOT/repo-fixups"
# Update issue templates
"$ROOT/update-issue-config" "$ROOT"
# Add and push
git add .
if ! git diff --cached --exit-code; then
git commit -m 'chore: Sync with WeblateOrg/meta'
git push
fi
echo
cd ..
done