Download wp-calypso/client/sites/deployments/use-github-repository-checks-query.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.16 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/deployments/use-github-repository-checks-query.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/sites/deployments/use-github-repository-checks-query.ts
-
curl -L -o use-github-repository-checks-query.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/sites/deployments/use-github-repository-checks-query.ts
1.16 kB
| 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-checks'; | |
| export type RepositoryChecks = { | |
| inferred_type: string; | |
| has_composer: boolean; | |
| has_vendor: boolean; | |
| suggested_directory: string; | |
| protected_paths: string[]; | |
| }; | |
| export const useGithubRepositoryChecksQuery = ( | |
| installationId?: number, | |
| repositoryOwner?: string, | |
| repositoryName?: string, | |
| repositoryBranch?: string | |
| ) => { | |
| return useQuery< RepositoryChecks >( { | |
| queryKey: [ | |
| GITHUB_DEPLOYMENTS_QUERY_KEY, | |
| GITHUB_BRANCHES_QUERY_KEY, | |
| installationId, | |
| repositoryOwner, | |
| repositoryName, | |
| repositoryBranch, | |
| ], | |
| queryFn: (): RepositoryChecks => | |
| wp.req.get( { | |
| path: addQueryArgs( '/hosting/github/repository/pre-connect-checks', { | |
| installation_id: installationId, | |
| repository_owner: repositoryOwner, | |
| repository_name: repositoryName, | |
| repository_branch: repositoryBranch, | |
| } ), | |
| apiNamespace: 'wpcom/v2', | |
| } ), | |
| meta: { | |
| persist: false, | |
| }, | |
| } ); | |
| }; | |