hunk.code_window:       let details = axiosError.response?.data.details;
         const { creds = {} } = options;
         // If no credentials were provided alter error from git to indicate repository is not found or is private
         if (
           !(creds.username && creds.password) &&
           details ===
             'authentication failed, please ensure that the git credentials are correct'
         ) {
           details =
  
hunk.labels: keep keep keep keep keep replace keep keep keep keep
hunk.after_edit:         (!(creds.username && creds.password) || !creds.gitCredentialId) &&
  
hunk.file_path: app/react/portainer/gitops/queries/useCheckRepo.ts
hunk.type: replace
file: import { AxiosError } from 'axios';
  import { useQuery } from 'react-query';
  
  import axios, { parseAxiosError } from '@/portainer/services/axios';
  
  interface Creds {
    username?: string;
    password?: string;
    gitCredentialId?: number;
  }
  interface CheckRepoOptions {
    creds?: Creds;
    force?: boolean;
    tlsSkipVerify?: boolean;
  }
  
  export function useCheckRepo(
    url: string,
    options: CheckRepoOptions,
    {
      enabled,
      onSettled,
    }: { enabled?: boolean; onSettled?(isValid?: boolean): void } = {}
  ) {
    return useQuery(
      ['git_repo_valid', url, options],
      () => checkRepo(url, options),
      {
        enabled: !!url && enabled,
        onSettled,
        retry: false,
      }
    );
  }
  
  export async function checkRepo(
    repository: string,
    { force, ...options }: CheckRepoOptions
  ): Promise<boolean> {
    try {
      await axios.post<string[]>(
        '/gitops/repo/refs',
        { repository, tlsSkipVerify: options.tlsSkipVerify, ...options.creds },
        force ? { params: { force } } : {}
      );
      return true;
    } catch (error) {
      throw parseAxiosError(error as Error, '', (axiosError: AxiosError) => {
        let details = axiosError.response?.data.details;
  
        const { creds = {} } = options;
        // If no credentials were provided alter error from git to indicate repository is not found or is private
        if (
          !(creds.username && creds.password) &&
          details ===
            'authentication failed, please ensure that the git credentials are correct'
        ) {
          details =
            'Git repository could not be found or is private, please ensure that the URL is correct or credentials are provided.';
        }
  
        const error = new Error(details);
        return { error, details };
      });
    }
  }
  