fix: fix: disinto init repo creation silently fails — wrong API endpoint for user namespace (#164)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
024517dcdc
commit
5324d5fcfb
1 changed files with 23 additions and 6 deletions
29
bin/disinto
29
bin/disinto
|
|
@ -915,12 +915,29 @@ setup_forge() {
|
|||
-H "Content-Type: application/json" \
|
||||
"${forge_url}/api/v1/orgs/${org_name}/repos" \
|
||||
-d "{\"name\":\"${repo_name}\",\"auto_init\":false,\"default_branch\":\"main\"}" >/dev/null 2>&1; then
|
||||
# Fallback: create under the human user namespace (johba)
|
||||
curl -sf -X POST \
|
||||
-H "Authorization: token ${admin_token:-${FORGE_TOKEN}}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${forge_url}/api/v1/users/${human_user}/repos" \
|
||||
-d "{\"name\":\"${repo_name}\",\"auto_init\":false,\"default_branch\":\"main\"}" >/dev/null 2>&1 || true
|
||||
# Fallback: create under the human user namespace using admin endpoint
|
||||
if [ -n "${admin_token:-}" ]; then
|
||||
if ! curl -sf -X POST \
|
||||
-H "Authorization: token ${admin_token}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${forge_url}/api/v1/admin/users/${org_name}/repos" \
|
||||
-d "{\"name\":\"${repo_name}\",\"auto_init\":false,\"default_branch\":\"main\"}" >/dev/null 2>&1; then
|
||||
echo "Error: failed to create repo '${repo_slug}' on Forgejo (admin endpoint)" >&2
|
||||
exit 1
|
||||
fi
|
||||
elif [ -n "${HUMAN_TOKEN:-}" ]; then
|
||||
if ! curl -sf -X POST \
|
||||
-H "Authorization: token ${HUMAN_TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${forge_url}/api/v1/user/repos" \
|
||||
-d "{\"name\":\"${repo_name}\",\"auto_init\":false,\"default_branch\":\"main\"}" >/dev/null 2>&1; then
|
||||
echo "Error: failed to create repo '${repo_slug}' on Forgejo (user endpoint)" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Error: failed to create repo '${repo_slug}' — no admin or human token available" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Add all bot users as collaborators with appropriate permissions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue