Skip to content

Commit 5f1840a

Browse files
committed
Show extended commit message for automated server syncs
1 parent 5bafd9d commit 5f1840a

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

generate_commit_notes.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# Header
4+
echo "Automated server sync"
5+
echo
6+
7+
strip_key() {
8+
name="$1"
9+
name="${name%\"}"
10+
name="${name#$2}"
11+
name="${name#=}"
12+
name="${name#_}"
13+
name="${name#\"}"
14+
echo "$name"
15+
}
16+
17+
# New and updated add-ons
18+
for file in $(git --no-pager diff --name-status --no-color --cached addons/*/addon | awk '$1 != "D" { print $NF}')
19+
do
20+
name="${file%/addon}"
21+
name="${name#addons/}"
22+
23+
versionold="$(git diff --cached "$file" | grep -P -- '^-version=')"
24+
versionold="$(strip_key "$versionold" "-version")"
25+
26+
if [ -n "$versionold" ]
27+
then
28+
versionnew="$(grep -P -- '^version=' "$file")"
29+
versionnew="$(strip_key "$versionnew" "version")"
30+
echo "- Updated $name from $versionold to $versionnew"
31+
else
32+
echo "- New add-on $name"
33+
fi
34+
done
35+
36+
# Updated translations
37+
find_updated_translations() {
38+
for file in $(git --no-pager diff --name-status --no-color --cached i18n/*.wad | awk '$1 != "D" { print $NF}')
39+
do
40+
file="${file#i18n/}"
41+
file="${file%/*.mo}"
42+
echo "$file"
43+
done
44+
}
45+
46+
for addon in $(find_updated_translations | sort --unique)
47+
do
48+
echo "- Updated translations for $addon"
49+
done
50+
51+
# Website map versions
52+
if [ -n "$(git diff --cached website_maps_i18n_version)" ]
53+
then
54+
echo "- Updated website map translations"
55+
fi
56+

wl/server/ThreadActivityAndGitHubSyncManager.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
package wl.server;
2121

2222
import java.io.BufferedReader;
23+
import java.io.File;
2324
import java.io.InputStreamReader;
2425
import java.net.Socket;
26+
import java.nio.file.Files;
2527
import java.util.HashMap;
2628
import wl.utils.UpdateList;
2729
import wl.utils.Utils;
@@ -63,13 +65,19 @@ public synchronized void sync() throws Exception {
6365
if (str != null) throw new Exception("Detected merge conflicts: " + str);
6466
}
6567
UpdateList.rebuildLists();
68+
69+
File commitNotes = Files.createTempFile(null, null).toFile();
6670
Utils.bash("bash", "-c", "git add .");
67-
Utils.bash("bash", "-c", "git commit -m 'Automated server sync'");
71+
Utils.bash(
72+
"bash", "-c", "./generate_commit_notes.sh > '" + commitNotes.getAbsolutePath() + "'");
73+
Utils.bash("bash", "-c", "git commit -F '" + commitNotes.getAbsolutePath() + "'");
6874
Utils.bash("bash", "-c",
6975
"git push https://" + Utils.config("githubusername") + ":" +
7076
Utils.config("githubtoken") +
7177
"@github.com/widelands/wl_addons_server.git master");
78+
7279
Utils.bash("bash", "-c", "git stash clear");
80+
commitNotes.delete();
7381
}
7482

7583
private static class Data {

0 commit comments

Comments
 (0)