Skip to content

Commit 0fc0766

Browse files
committed
fix: Fix plugins generated from the plugin template having the same plugin ID
1 parent 6a5afc6 commit 0fc0766

File tree

3 files changed

+93
-3
lines changed

3 files changed

+93
-3
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,22 @@ jobs:
6363
6464
echo "submodule-matrix=$(cat submodules.json)" >> $GITHUB_OUTPUT
6565
66+
- name: Update README stats
67+
run: |
68+
STAT_OUTPUT=$(bash ./scripts/_stat.sh)
69+
70+
# Replace everything from "## Repository Manifest" to end of file
71+
BEFORE=$(sed '/^## Repository Manifest$/,$d' README.md)
72+
printf '%s\n%s\n' "$BEFORE" "$STAT_OUTPUT" > README.md
73+
6674
- name: Commit Metadata
6775
if: github.event_name != 'pull_request' && github.event.repository.fork == false
6876
run: |
6977
git config --global user.name 'github-actions[bot]'
7078
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
7179
7280
# Stage the changes
73-
git add metadata.json
81+
git add metadata.json README.md
7482
7583
# Commit only if there are changes
7684
if git commit -m "chore: Add plugin metadata"; then

scripts/_gen_metadata.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
#!/bin/bash
22

33
parse_plugin() {
4+
# Abstract:
5+
# plugin_name = unique hash in the git repository that will not change unless the history is force deleted.
6+
# commit_id = latest commit from the repository
7+
#
8+
# We need to use an ID for a plugin name because we have no other static information that will *always*
9+
# identify a repository. Ex: using actual owner/repo if the user changed their name or repo name it would break millennium.
10+
411
local plugins_dir=$1
512
local submodule=$2
613
local submodule_path="$plugins_dir/$submodule"
714
local plugin_name commit_id
8-
9-
plugin_name=$(git -C "$submodule_path" rev-list --max-parents=0 HEAD 2>/dev/null | tr -d '\n')
15+
16+
# Get the first commit that isn't from me (i.e if they used the plugin template)
17+
plugin_name=$(git -C "$submodule_path" log --format='%H %ae' --reverse 2>/dev/null | grep -Fv '81448108+shdwmtr@users.noreply.github.com' | head -1 | cut -d' ' -f1 | tr -d '\n')
18+
# Fallback to root commit if all commits are ours
19+
[[ -z "$plugin_name" ]] && plugin_name=$(git -C "$submodule_path" rev-list --max-parents=0 HEAD 2>/dev/null | tr -d '\n')
1020
commit_id=$(git -C "$submodule_path" rev-parse HEAD 2>/dev/null | tr -d '\n')
1121

1222
echo "{\"id\": \"$plugin_name\", \"commitId\": \"$commit_id\"}"

scripts/_stat.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/bin/bash
2+
3+
PYTHON_PLUGINS=()
4+
LUA_PLUGINS=()
5+
6+
while IFS= read -r line; do
7+
submodule_path=$(echo "$line" | awk '{print $2}')
8+
9+
if [[ -z "$submodule_path" ]]; then
10+
continue
11+
fi
12+
13+
plugin_json="$submodule_path/plugin.json"
14+
plugin_name=$(basename "$submodule_path")
15+
16+
if [[ -f "$plugin_json" ]]; then
17+
backend_type=$(jq -r '.backendType // "undefined"' "$plugin_json" 2>/dev/null)
18+
use_backend=$(jq -r 'if has("useBackend") then .useBackend else true end' "$plugin_json" 2>/dev/null)
19+
20+
if [[ "$use_backend" == "false" || "$backend_type" == "lua" ]]; then
21+
LUA_PLUGINS+=("$plugin_name")
22+
else
23+
PYTHON_PLUGINS+=("$plugin_name")
24+
fi
25+
else
26+
echo "Warning: No plugin.json found in $submodule_path"
27+
fi
28+
done < <(git submodule status)
29+
30+
TOTAL_PLUGINS=$(( ${#LUA_PLUGINS[@]} + ${#PYTHON_PLUGINS[@]} ))
31+
32+
echo "## Repository Manifest"
33+
echo ""
34+
35+
# Determine the max rows needed
36+
max_rows=${#LUA_PLUGINS[@]}
37+
if (( ${#PYTHON_PLUGINS[@]} > max_rows )); then
38+
max_rows=${#PYTHON_PLUGINS[@]}
39+
fi
40+
41+
echo "The following table describes the remaining deprecated Python plugins that need to be ported to Lua."
42+
echo "Python is no longer officially supported by Millennium and will be removed entirely in a future update."
43+
44+
echo ""
45+
echo "**Total**: ${TOTAL_PLUGINS}"
46+
echo " * **Lua**: ${#LUA_PLUGINS[@]}"
47+
echo " * **Python**: ${#PYTHON_PLUGINS[@]}"
48+
echo ""
49+
echo ""
50+
51+
echo "| Lua | Python |"
52+
echo "|-----|--------|"
53+
54+
for (( i=0; i<max_rows; i++ )); do
55+
if (( i < ${#LUA_PLUGINS[@]} )); then
56+
lua_num="$(( i + 1 ))"
57+
lua_name="${LUA_PLUGINS[$i]}"
58+
else
59+
lua_num=""
60+
lua_name=""
61+
fi
62+
63+
if (( i < ${#PYTHON_PLUGINS[@]} )); then
64+
py_num="$(( i + 1 ))"
65+
py_name="${PYTHON_PLUGINS[$i]}"
66+
else
67+
py_num=""
68+
py_name=""
69+
fi
70+
71+
echo "| $lua_name | $py_name |"
72+
done

0 commit comments

Comments
 (0)