What:gitea.sh 的 wiki-repo 允許型別清單、wiki 技能 SKILL.md 的頁型清單,以及 check-wiki-rules.sh 的驗證案例,同步收錄 LEARN 頁型。 Why:jsc-log 新增 LEARN wiki 頁型,若允許清單未收錄,wiki-repo LEARN 會以 unknown type(exit 2)被擋下,學習紀錄頁無法解析存放位置。 How:resolve_wiki_repo 的 case 白名單加入 LEARN,解析順序維持 JSC_WIKI_REPO_LEARN 優先、退回 JSC_WIKI_REPO、不跨型別代用;check-wiki-rules.sh 補上 LEARN 專屬變數優先與退回共用預設兩個案例;SKILL.md 允許頁型清單同步更新。 Who:jsc-gitea wiki 技能與其呼叫方(jsc-log 等)的 wiki 頁型解析功能。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
73 lines
1.8 KiB
Bash
Executable File
73 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
# check-wiki-rules — 驗證 wiki repo 解析與 hash-id 規則。
|
|
set -eu
|
|
|
|
dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
gitea="$dir/gitea.sh"
|
|
hash_id="$dir/hash-id"
|
|
|
|
fail() {
|
|
printf '%s\n' "$1" >&2
|
|
exit 1
|
|
}
|
|
|
|
expect_eq() {
|
|
got=$1
|
|
want=$2
|
|
label=$3
|
|
[ "$got" = "$want" ] || fail "$label: want=$want got=$got"
|
|
}
|
|
|
|
check_repo() {
|
|
type=$1
|
|
label=$2
|
|
want=$3
|
|
shift 3
|
|
got=$(env -i PATH="${PATH:-/usr/bin:/bin}" "$@" "$gitea" wiki-repo "$type")
|
|
expect_eq "$got" "$want" "$label"
|
|
}
|
|
|
|
check_hash() {
|
|
input=$1
|
|
want=$2
|
|
got=$("$hash_id" "$input")
|
|
expect_eq "$got" "$want" "hash-id $input"
|
|
}
|
|
|
|
check_repo REPO 'REPO specific wins' 'records/REPO' \
|
|
JSC_WIKI_REPO_REPO='records/REPO' \
|
|
JSC_WIKI_REPO_ANALYZE='knowledges/ANALYZE' \
|
|
JSC_WIKI_REPO='shared/wiki'
|
|
|
|
check_repo REPO 'REPO falls back to shared only' 'shared/wiki' \
|
|
JSC_WIKI_REPO_ANALYZE='knowledges/ANALYZE' \
|
|
JSC_WIKI_REPO='shared/wiki'
|
|
|
|
check_repo ANALYZE 'ANALYZE specific wins' 'knowledges/ANALYZE' \
|
|
JSC_WIKI_REPO_REPO='records/REPO' \
|
|
JSC_WIKI_REPO_ANALYZE='knowledges/ANALYZE' \
|
|
JSC_WIKI_REPO='shared/wiki'
|
|
|
|
check_repo ANALYZE 'ANALYZE falls back to shared only' 'shared/wiki' \
|
|
JSC_WIKI_REPO_REPO='records/REPO' \
|
|
JSC_WIKI_REPO='shared/wiki'
|
|
|
|
check_repo LEARN 'LEARN specific wins' 'lessons/LEARN' \
|
|
JSC_WIKI_REPO_LEARN='lessons/LEARN' \
|
|
JSC_WIKI_REPO='shared/wiki'
|
|
|
|
check_repo LEARN 'LEARN falls back to shared only' 'shared/wiki' \
|
|
JSC_WIKI_REPO_LOG='records/LOG' \
|
|
JSC_WIKI_REPO='shared/wiki'
|
|
|
|
check_repo ERROR 'ERROR uses its own repo' 'errors/wiki' \
|
|
JSC_WIKI_REPO_ERROR='errors/wiki' \
|
|
JSC_WIKI_REPO='shared/wiki'
|
|
|
|
check_hash 'case-2' 'H5172CB7'
|
|
check_hash 'case-11' 'HA9A6662'
|
|
check_hash 'case-1' 'HB6EC7FD'
|
|
check_hash 'case-12' 'HCCA8D42'
|
|
|
|
printf '%s\n' 'OK'
|