Spaces:
Paused
Paused
Download node_modules/@huggingface/hub/src/lib/delete-branch.ts from ken-q/opencode-home: direct link, hf CLI and curl.
- Browser
- Download file 816 Bytes
-
https://huggingface.co/spaces/ken-q/opencode-home/resolve/main/node_modules/%40huggingface/hub/src/lib/delete-branch.ts
- Command line
-
hf download hf://spaces/ken-q/opencode-home/node_modules/@huggingface/hub/src/lib/delete-branch.ts
-
curl -L -o delete-branch.ts https://huggingface.co/spaces/ken-q/opencode-home/resolve/main/node_modules/%40huggingface/hub/src/lib/delete-branch.ts
816 Bytes
| import { HUB_URL } from "../consts"; | |
| import { createApiError } from "../error"; | |
| import type { AccessToken, RepoDesignation } from "../types/public"; | |
| import { toRepoId } from "../utils/toRepoId"; | |
| export async function deleteBranch(params: { | |
| repo: RepoDesignation; | |
| /** | |
| * The name of the branch to delete | |
| */ | |
| branch: string; | |
| hubUrl?: string; | |
| accessToken?: AccessToken; | |
| fetch?: typeof fetch; | |
| }): Promise<void> { | |
| const repoId = toRepoId(params.repo); | |
| const res = await (params.fetch ?? fetch)( | |
| `${params.hubUrl ?? HUB_URL}/api/${repoId.type}s/${repoId.name}/branch/${encodeURIComponent(params.branch)}`, | |
| { | |
| method: "DELETE", | |
| headers: { | |
| ...(params.accessToken && { | |
| Authorization: `Bearer ${params.accessToken}`, | |
| }), | |
| }, | |
| }, | |
| ); | |
| if (!res.ok) { | |
| throw await createApiError(res); | |
| } | |
| } | |