public function download(Application $application, string $commit, string $targetFile): bool
    {
        $username = $application->parameter('gh.owner');
        $repository = $application->parameter('gh.repo');

        if (!$username || !$repository) {
            throw new VCSException(self::ERR_APP_MISCONFIGURED);
        }

        $endpoint = implode('/', [
            'repos',
            rawurlencode($username),
            rawurlencode($repository),
            'tarball',
            rawurlencode($commit),
        ]);

        $options = [
            'sink' => new LazyOpenStream($targetFile, 'w+'),
        ];

        try {
            $response = $this->guzzle->request('GET', $endpoint, $options);
        } catch (Exception $e) {
            throw new VCSException($e->getMessage(), $e->getCode(), $e);
        }

        return ($response->getStatusCode() === 200);
    }
public function download(Application $application, string $commit, string $targetFile): bool
    {
        $username = $application->parameter('gh.owner');
        $repository = $application->parameter('gh.repo');

        if (!$username || !$repository) {
            throw new VCSException(self::ERR_APP_MISCONFIGURED);
        }

        $endpoint = implode('/', [
            'repos',
            rawurlencode($username),
            rawurlencode($repository),
            'tarball',
            rawurlencode($commit),
        ]);

        $options = [
            'sink' => new LazyOpenStream($targetFile, 'w+'),
        ];

        try {
            $response = $this->guzzle->request('GET', $endpoint, $options);
        } catch (Exception $e) {
            throw new VCSException($e->getMessage(), $e->getCode(), $e);
        }

        return ($response->getStatusCode() === 200);
    }
public function download ( Application $ application , string $ commit , string $ targetFile ) : bool { $ username = $ application -> parameter ( 'gh.owner' ) ; $ repository = $ application -> parameter ( 'gh.repo' ) ; if ( ! $ username || ! $ repository ) { throw new VCSException ( self :: ERR_APP_MISCONFIGURED ) ; } $ endpoint = implode ( '/' , [ 'repos' , rawurlencode ( $ username ) , rawurlencode ( $ repository ) , 'tarball' , rawurlencode ( $ commit ) , ] ) ; $ options = [ 'sink' => new LazyOpenStream ( $ targetFile , 'w+' ) , ] ; try { $ response = $ this -> guzzle -> request ( 'GET' , $ endpoint , $ options ) ; } catch ( Exception $ e ) { throw new VCSException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } return ( $ response -> getStatusCode ( ) === 200 ) ; }
Get content of archives in a repository

@link http://developer.github.com/v3/repos/contents/

@param Application $application
@param string $commit
@param string $targetFile

@throws VCSException

@return bool
Get content of archives in a repository