lib/Github/Api/Repository/Contents.php
public function exists($username, $repository, $path, $reference = null)
    {
        $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents';

        if (null !== $path) {
            $url .= '/'.rawurlencode($path);
        }

        try {
            $response = $this->head($url, [
                'ref' => $reference,
            ]);

            if ($response->getStatusCode() !== 200) {
                return false;
            }
        } catch (TwoFactorAuthenticationRequiredException $ex) {
            throw $ex;
        } catch (\Exception $ex) {
            return false;
        }

        return true;
    }
public function exists($username, $repository, $path, $reference = null)
    {
        $url = '/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/contents';

        if (null !== $path) {
            $url .= '/'.rawurlencode($path);
        }

        try {
            $response = $this->head($url, [
                'ref' => $reference,
            ]);

            if ($response->getStatusCode() !== 200) {
                return false;
            }
        } catch (TwoFactorAuthenticationRequiredException $ex) {
            throw $ex;
        } catch (\Exception $ex) {
            return false;
        }

        return true;
    }
public function exists ( $ username , $ repository , $ path , $ reference = null ) { $ url = '/repos/' . rawurlencode ( $ username ) . '/' . rawurlencode ( $ repository ) . '/contents' ; if ( null !== $ path ) { $ url .= '/' . rawurlencode ( $ path ) ; } try { $ response = $ this -> head ( $ url , [ 'ref' => $ reference , ] ) ; if ( $ response -> getStatusCode ( ) !== 200 ) { return false ; } } catch ( TwoFactorAuthenticationRequiredException $ ex ) { throw $ ex ; } catch ( \ Exception $ ex ) { return false ; } return true ; }
Checks that a given path exists in a repository.

@param string      $username   the user who owns the repository
@param string      $repository the name of the repository
@param string      $path       path of file to check
@param null|string $reference  reference to a branch or commit

@return bool
Checks that a given path exists in a repository .