react-code-dataset / wp-calypso /client /sites /deployments /use-github-repository-branches-query.ts
react-code-dataset / wp-calypso /client /sites /deployments /use-github-repository-branches-query.ts
Download wp-calypso/client/sites/deployments/use-github-repository-branches-query.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 908 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/deployments/use-github-repository-branches-query.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/sites/deployments/use-github-repository-branches-query.ts
-
curl -L -o use-github-repository-branches-query.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/deployments/use-github-repository-branches-query.ts
908 Bytes
| import { useQuery } from '@tanstack/react-query'; | |
| import { addQueryArgs } from '@wordpress/url'; | |
| import wp from 'calypso/lib/wp'; | |
| import { GITHUB_DEPLOYMENTS_QUERY_KEY } from './constants'; | |
| const GITHUB_BRANCHES_QUERY_KEY = 'github-repository-branches'; | |
| export const useGithubRepositoryBranchesQuery = ( | |
| installationId?: number, | |
| repositoryOwner?: string, | |
| repositoryName?: string | |
| ) => { | |
| return useQuery< string[] >( { | |
| queryKey: [ | |
| GITHUB_DEPLOYMENTS_QUERY_KEY, | |
| GITHUB_BRANCHES_QUERY_KEY, | |
| installationId, | |
| repositoryOwner, | |
| repositoryName, | |
| ], | |
| queryFn: (): string[] => | |
| wp.req.get( { | |
| path: addQueryArgs( '/hosting/github/repository/branches', { | |
| installation_id: installationId, | |
| repository_owner: repositoryOwner, | |
| repository_name: repositoryName, | |
| } ), | |
| apiNamespace: 'wpcom/v2', | |
| } ), | |
| meta: { | |
| persist: false, | |
| }, | |
| enabled: !! installationId, | |
| } ); | |
| }; | |