adopt 的冪等改靠「先讀 /dependencies」:真 Gitea 對重複相依回 500 不是 409(inkstone/ISEP#133)
真 Gitea 實跑(hub=InkStoneCo#44、子票=ISEP#133):第一次 POST 成功、/blocks 回 #44、 清空快取後 has 靠 /blocks 判「在」;第二次 POST 回 500——假伺服器原本猜 409,adopt 第二次會炸。 add_dependency() 改成先讀 parent 的 /dependencies,邊在就不 POST(判準是 Gitea 的事實,不是回應碼); 假伺服器改照真的回 500;A41 56→57 條。測完 DELETE 復原(201,/blocks 空)。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0178ef1fGw3XeZtpN7LaZrm4
This commit is contained in:
+11
-2
@@ -670,13 +670,22 @@ def _deps(owner, repo, num):
|
||||
|
||||
|
||||
def add_dependency(parent, child):
|
||||
"""讓 `child` 成為 `parent` 的相依(兩個都是 (owner, repo, num))。**冪等**:邊已經在
|
||||
(Gitea 回 409)就當成功,回 False——`mainline adopt` 補收同一張票兩次不該炸。
|
||||
"""讓 `child` 成為 `parent` 的相依(兩個都是 (owner, repo, num))。**冪等**:
|
||||
先讀 parent 的 `/dependencies`,邊已經在就不 POST、回 False——`mainline adopt`
|
||||
補收同一張票兩次不該炸。
|
||||
🔴 冪等**不能靠回應碼**:2026-09-07 對真 Gitea 實測,重複相依回的是 **500**(不是想像中的 409)
|
||||
——判準改成「Gitea 現在有沒有這條邊」這個事實;409 仍容忍(別的版本可能這樣回)。
|
||||
`subtask` 與 `mainline adopt`(inkstone/ISEP#133)都走這一支:掛相依只有一條路,
|
||||
而且走的是 `api()`——離線測試把 `api()` 換成錄音機時才錄得到它。"""
|
||||
global _TOLERATE
|
||||
po, pr, pn = parent
|
||||
co, cr, cn = child
|
||||
want = f"{co}/{cr}#{cn}"
|
||||
have = api(f"/repos/{po}/{pr}/issues/{pn}/dependencies?limit=100") or []
|
||||
for d in have:
|
||||
full = ((d.get("repository") or {}).get("full_name")) if isinstance(d, dict) else None
|
||||
if full and f"{full}#{d.get('number')}" == want:
|
||||
return False # 已經是相依
|
||||
_TOLERATE = (409,)
|
||||
try:
|
||||
r = api(f"/repos/{po}/{pr}/issues/{pn}/dependencies", {"owner": co, "repo": cr, "index": cn})
|
||||
|
||||
Reference in New Issue
Block a user