cpliakas / git-wrapper

A PHP wrapper around the Git command line utility.
MIT License
505 stars 68 forks source link

Git Clone: Wrapper output is not same as during real command execution #207

Closed roma-glushko closed 3 years ago

roma-glushko commented 4 years ago

Description I'm using cpliakas/git-wrapper to clone the repository. My code snippet is pretty much like this:

$gitWrapper = new GitWrapper();

        $logger = new Logger('git');
        $logger->pushHandler(new StreamHandler('tmp/git.log', Logger::DEBUG));

        $gitWrapper->addLoggerEventSubscriber(new GitLoggerEventSubscriber($logger));

        $gitWrapper->streamOutput();
        $gitWrapper->setTimeout(0);

        $git = $gitWrapper->cloneRepository(
            $projectRepository,
            $destDir,
            [
                'depth' => '1',
                'branch' => 'master',
                'verbose' => true,
            ]
        );

I want to be able to clone my repos and show interactive output to show progress of execution as repos may be huge and it may take up to 1h to clone them even with --depth 1 --branch master params.

Expected Result

I want to see all output that git clone command usually shows during git command execution (just a little part of it):

2020-03-22_11-47-52

Actual Result

I see only "Cloning into 'tmp/cab'..." part of the output. The log file contains these records:

[2020-03-22T09:41:28.219957+00:00] module-watcher.INFO: Git command preparing to run {"command":"'/usr/local/bin/git' 'clone' '--depth' '1' '--branch' 'master' 'git@github.com:X/Y.git' 'tmp/cab'"} []
[2020-03-22T09:41:28.885792+00:00] module-watcher.DEBUG: Cloning into 'tmp/cab'...  {"error":true,"command":"'/usr/local/bin/git' 'clone' '--depth' '1' '--branch' 'master' 'git@github.com:X/Y.git' 'tmp/cab'"} []

I also tried to use HTTPs link to the repo, but the result is the same.

roma-glushko commented 4 years ago

Progress flag seems to be helpful here:

$git = $gitWrapper->cloneRepository(
            $projectRepository,
            $destDir,
            [
                'depth' => '1',
                'branch' => 'master',
                'verbose' => true,
                'progress' => true,
            ]
        );

Now it's possible to follow the git clone progress:

2020-03-22_13-34-34

TomasVotruba commented 3 years ago

Thank you for the issue!


The work of this package continues in https://github.com/symplify/symplify

See https://github.com/cpliakas/git-wrapper/issues/225