Skip to content

Commit 3e3cf49

Browse files
committed
update config_update
1 parent 7924b42 commit 3e3cf49

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

utils.sh

+23-15
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ get_rv_prebuilts() {
4242
local cl_dir=${patches_src%/*}
4343
cl_dir=${TEMP_DIR}/${cl_dir,,}-rv
4444
[ -d "$cl_dir" ] || mkdir "$cl_dir"
45-
: >"${cl_dir}/changelog.md"
4645
for src_ver in "$cli_src CLI $cli_ver" "$integrations_src Integrations $integrations_ver" "$patches_src Patches $patches_ver"; do
4746
set -- $src_ver
4847
local src=$1 tag=$2 ver=${3-} ext
@@ -57,7 +56,6 @@ get_rv_prebuilts() {
5756

5857
local rv_rel="https://api.github.com/repos/${src}/releases" name_ver
5958
if [ "$ver" = "dev" ]; then
60-
rv_rel+="/tags/$(gh_req "$rv_rel" - | jq -r '.[0] | .tag_name')"
6159
name_ver="*-dev*"
6260
elif [ "$ver" = "latest" ]; then
6361
rv_rel+="/latest"
@@ -76,32 +74,34 @@ get_rv_prebuilts() {
7674
if [ -z "$file" ]; then
7775
local resp asset name
7876
resp=$(gh_req "$rv_rel" -) || return 1
77+
if [ "$ver" = "dev" ]; then resp=$(jq -r '.[0]' <<<"$resp"); fi
7978
tag_name=$(jq -r '.tag_name' <<<"$resp")
8079
asset=$(jq -e -r ".assets[] | select(.name | endswith(\"$ext\"))" <<<"$resp") || return 1
8180
url=$(jq -r .url <<<"$asset")
8281
name=$(jq -r .name <<<"$asset")
8382
file="${dir}/${name}"
8483
gh_dl "$file" "$url" >&2 || return 1
8584
if [ "$tag" = "Integrations" ]; then integs_file=$file; fi
85+
echo "$tag: $(cut -d/ -f1 <<<"$src")/${name} " >>"${cl_dir}/changelog.md"
8686
else
8787
name=$(basename "$file")
8888
tag_name=$(cut -d'-' -f3- <<<"$name")
8989
tag_name=v${tag_name%.*}
9090
if [ "$tag_name" = "v" ]; then abort; fi
9191
fi
9292

93-
echo "$tag: $(cut -d/ -f1 <<<"$src")/${name} " >>"${cl_dir}/changelog.md"
9493
echo -n "$file "
9594
if [ "$tag" = "Patches" ]; then
9695
name="patches-${tag_name}.json"
9796
file="${dir}/${name}"
9897
if [ ! -f "$file" ]; then
9998
resp=$(gh_req "$rv_rel" -) || return 1
99+
if [ "$ver" = "dev" ]; then resp=$(jq -r '.[0]' <<<"$resp"); fi
100100
url=$(jq -e -r '.assets[] | select(.name | endswith("json")) | .url' <<<"$resp") || return 1
101101
gh_dl "$file" "$url" >&2 || return 1
102+
echo -e "[Changelog](https://github.com/${src}/releases/tag/${tag_name})\n" >>"${cl_dir}/changelog.md"
102103
fi
103104
echo -n "$file "
104-
echo -e "[Changelog](https://github.com/${src}/releases/tag/${tag_name})\n" >>"${cl_dir}/changelog.md"
105105
fi
106106
done
107107
echo
@@ -116,7 +116,7 @@ get_rv_prebuilts() {
116116
rm "${integs_file}" || return 1
117117
zip -0rq "${integs_file}" . || return 1
118118
) >&2; then
119-
epr "Patching revanced-integrations failed"
119+
echo >&2 "Patching revanced-integrations failed"
120120
fi
121121
rm -r "${integs_file}-zip" || :
122122

@@ -155,26 +155,34 @@ config_update() {
155155
enabled=$(toml_get "$t" enabled) || enabled=true
156156
if [ "$enabled" = false ]; then continue; fi
157157
PATCHES_SRC=$(toml_get "$t" patches-source) || PATCHES_SRC=$DEF_PATCHES_SRC
158-
if [[ -v sources[$PATCHES_SRC] ]]; then
159-
if [ "${sources[$PATCHES_SRC]}" = 1 ]; then
158+
PATCHES_VER=$(toml_get "$t" patches-version) || PATCHES_VER=$DEF_PATCHES_VER
159+
if [[ -v sources["$PATCHES_SRC/$PATCHES_VER"] ]]; then
160+
if [ "${sources["$PATCHES_SRC/$PATCHES_VER"]}" = 1 ]; then
160161
conf+="$t"
161162
conf+=$'\n'
162163
fi
163164
else
164-
sources[$PATCHES_SRC]=0
165-
if ! last_patches=$(gh_req "https://api.github.com/repos/${PATCHES_SRC}/releases/latest" - |
166-
jq -e -r '.assets[] | select(.name | endswith("jar")) | .name'); then
165+
sources["$PATCHES_SRC/$PATCHES_VER"]=0
166+
local rv_rel="https://api.github.com/repos/${PATCHES_SRC}/releases"
167+
if [ "$PATCHES_VER" = "dev" ]; then
168+
last_patches=$(gh_req "$rv_rel" - | jq -e -r '.[0]')
169+
elif [ "$PATCHES_VER" = "latest" ]; then
170+
last_patches=$(gh_req "$rv_rel/latest" -)
171+
else
172+
last_patches=$(gh_req "$rv_rel/tags/${ver}" -)
173+
fi
174+
175+
if ! last_patches=$(jq -e -r '.assets[] | select(.name | endswith("jar")) | .name' <<<"$last_patches"); then
167176
abort oops
168177
fi
169-
cur_patches=$(sed -n "s/.*Patches: ${PATCHES_SRC%%/*}\/\(.*\)/\1/p" build.md | xargs)
170-
if [ "$cur_patches" ] && [ "$last_patches" ]; then
171-
if [ "${cur_patches}" != "$last_patches" ]; then
172-
sources[$PATCHES_SRC]=1
178+
if [ "$last_patches" ]; then
179+
if ! OP=$(grep "^Patches: ${PATCHES_SRC%%/*}/" build.md | grep "$last_patches"); then
180+
sources["$PATCHES_SRC/$PATCHES_VER"]=1
173181
prcfg=true
174182
conf+="$t"
175183
conf+=$'\n'
176184
else
177-
echo "Patches: ${PATCHES_SRC%%/*}/${cur_patches} " >>"$TEMP_DIR"/skipped
185+
echo "$OP" >>"$TEMP_DIR"/skipped
178186
fi
179187
fi
180188
fi

0 commit comments

Comments
 (0)