public function ensureGitRemote($dir, $url)
    {
        if (!file_exists($dir . '/.git')) {
            throw new \InvalidArgumentException('The directory is not a Git repository');
        }
        $this->git->ensureInstalled();
        $currentUrl = $this->git->getConfig(
            sprintf('remote.%s.url', $this->config->get('detection.git_remote_name')),
            $dir
        );
        if (!$currentUrl) {
            $this->git->execute(
                ['remote', 'add', $this->config->get('detection.git_remote_name'), $url],
                $dir,
                true
            );
        } elseif ($currentUrl !== $url) {
            $this->git->execute([
                'remote',
                'set-url',
                $this->config->get('detection.git_remote_name'),
                $url
            ], $dir, true);
        }
    }
public function ensureGitRemote($dir, $url)
    {
        if (!file_exists($dir . '/.git')) {
            throw new \InvalidArgumentException('The directory is not a Git repository');
        }
        $this->git->ensureInstalled();
        $currentUrl = $this->git->getConfig(
            sprintf('remote.%s.url', $this->config->get('detection.git_remote_name')),
            $dir
        );
        if (!$currentUrl) {
            $this->git->execute(
                ['remote', 'add', $this->config->get('detection.git_remote_name'), $url],
                $dir,
                true
            );
        } elseif ($currentUrl !== $url) {
            $this->git->execute([
                'remote',
                'set-url',
                $this->config->get('detection.git_remote_name'),
                $url
            ], $dir, true);
        }
    }
public function ensureGitRemote ( $ dir , $ url ) { if ( ! file_exists ( $ dir . '/.git' ) ) { throw new \ InvalidArgumentException ( 'The directory is not a Git repository' ) ; } $ this -> git -> ensureInstalled ( ) ; $ currentUrl = $ this -> git -> getConfig ( sprintf ( 'remote.%s.url' , $ this -> config -> get ( 'detection.git_remote_name' ) ) , $ dir ) ; if ( ! $ currentUrl ) { $ this -> git -> execute ( [ 'remote' , 'add' , $ this -> config -> get ( 'detection.git_remote_name' ) , $ url ] , $ dir , true ) ; } elseif ( $ currentUrl !== $ url ) { $ this -> git -> execute ( [ 'remote' , 'set-url' , $ this -> config -> get ( 'detection.git_remote_name' ) , $ url ] , $ dir , true ) ; } }
Ensure there is an appropriate Git remote in the repository.

@param string $dir
The repository directory.
@param string $url
The Git URL.
Ensure there is an appropriate Git remote in the repository .