GrumPHP\Event\Subscriber\StashUnstagedChangesSubscriber::doSaveStash PHP Method

doSaveStash() private method

Check if there is a pending diff and stash the changes.
private doSaveStash ( )
    private function doSaveStash()
    {
        $pending = $this->repository->getWorkingCopy()->getDiffPending();
        if (!count($pending->getFiles())) {
            return;
        }
        try {
            $this->io->write('<fg=yellow>Detected unstaged changes... Stashing them!</fg=yellow>');
            $this->repository->run('stash', ['save', '--quiet', '--keep-index', uniqid('grumphp')]);
        } catch (Exception $e) {
            // No worries ...
            $this->io->write(sprintf('<fg=red>Failed stashing changes: %s</fg=red>', $e->getMessage()));
            return;
        }
        $this->stashIsApplied = true;
        $this->registerShutdownHandler();
    }