feat(gitea): gitea.sh 新增 pr-depend(前置 PR 依賴阻擋)與 repo-set(描述/網頁)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,9 @@
|
|||||||
# gitea.sh wiki-get <owner>/<repo> <page> # 印出 wiki 頁 markdown;不存在時 exit 4
|
# gitea.sh wiki-get <owner>/<repo> <page> # 印出 wiki 頁 markdown;不存在時 exit 4
|
||||||
# gitea.sh wiki-put <owner>/<repo> <page> <file> # 建立或更新 wiki 頁(內容取自檔案)
|
# gitea.sh wiki-put <owner>/<repo> <page> <file> # 建立或更新 wiki 頁(內容取自檔案)
|
||||||
# gitea.sh pr-create <owner>/<repo> <head> <base> <title> <body-file> # 建立 PR,印出 PR URL
|
# gitea.sh pr-create <owner>/<repo> <head> <base> <title> <body-file> # 建立 PR,印出 PR URL
|
||||||
|
# gitea.sh pr-depend <owner>/<repo> <pr-index> <dep-owner>/<dep-repo> <dep-index>
|
||||||
|
# 把 PR 掛上前置 PR 依賴;依賴未關閉前 Gitea 會阻擋合併
|
||||||
|
# gitea.sh repo-set <owner>/<repo> <description> [website] # 設定 repo 描述與網頁
|
||||||
# gitea.sh api <METHOD> <path> [json-file] # 原始 API 呼叫(path 以 /repos/... 起始)
|
# gitea.sh api <METHOD> <path> [json-file] # 原始 API 呼叫(path 以 /repos/... 起始)
|
||||||
# 環境變數: GITEA_HOST(例 https://gitea.jsc.idv.tw)、GITEA_TOKEN
|
# 環境變數: GITEA_HOST(例 https://gitea.jsc.idv.tw)、GITEA_TOKEN
|
||||||
set -eu
|
set -eu
|
||||||
@@ -117,6 +120,34 @@ print(json.dumps({"head":sys.argv[1],"base":sys.argv[2],"title":sys.argv[3],
|
|||||||
' "$head" "$base" "$title" "$body_file" > "$tmp"
|
' "$head" "$base" "$title" "$body_file" > "$tmp"
|
||||||
req POST "/repos/$or/pulls" "$tmp" | json_field html_url
|
req POST "/repos/$or/pulls" "$tmp" | json_field html_url
|
||||||
rm -f "$tmp" ;;
|
rm -f "$tmp" ;;
|
||||||
|
pr-depend)
|
||||||
|
or="${1:?owner/repo required}"; idx="${2:?pr index required}"
|
||||||
|
dep_or="${3:?dep owner/repo required}"; dep_idx="${4:?dep index required}"
|
||||||
|
tmp=$(mktemp)
|
||||||
|
python3 -c '
|
||||||
|
import json,sys
|
||||||
|
o,r=sys.argv[1].split("/",1)
|
||||||
|
print(json.dumps({"owner":o,"repo":r,"index":int(sys.argv[2])}))
|
||||||
|
' "$dep_or" "$dep_idx" > "$tmp"
|
||||||
|
if ! out=$(req POST "/repos/$or/issues/$idx/dependencies" "$tmp"); then
|
||||||
|
rm -f "$tmp"; printf '%s\n' "$out" >&2; exit 4
|
||||||
|
fi
|
||||||
|
rm -f "$tmp"
|
||||||
|
echo "OK $or#$idx depends on $dep_or#$dep_idx" ;;
|
||||||
|
repo-set)
|
||||||
|
or="${1:?owner/repo required}"; desc="${2:?description required}"; site="${3:-}"
|
||||||
|
tmp=$(mktemp)
|
||||||
|
python3 -c '
|
||||||
|
import json,sys
|
||||||
|
b={"description":sys.argv[1]}
|
||||||
|
if len(sys.argv)>2 and sys.argv[2]: b["website"]=sys.argv[2]
|
||||||
|
print(json.dumps(b))
|
||||||
|
' "$desc" "$site" > "$tmp"
|
||||||
|
if ! out=$(req PATCH "/repos/$or" "$tmp"); then
|
||||||
|
rm -f "$tmp"; printf '%s\n' "$out" >&2; exit 4
|
||||||
|
fi
|
||||||
|
rm -f "$tmp"
|
||||||
|
echo "OK $or" ;;
|
||||||
api)
|
api)
|
||||||
method="${1:?METHOD}"; path="${2:?path}"; body="${3:-}"
|
method="${1:?METHOD}"; path="${2:?path}"; body="${3:-}"
|
||||||
req "$method" "$path" $body ;;
|
req "$method" "$path" $body ;;
|
||||||
|
|||||||
Reference in New Issue
Block a user