Check whether a branch exists on a remote.

@param string $remote
@param string $branchName
@param null   $dir
@param bool   $mustRun

@return bool
774031
public function remoteBranchExists($remote, $branchName, $dir = null, $mustRun = false)
    {
        $args = ['ls-remote', $remote, $branchName];
        $result = $this->execute($args, $dir, $mustRun);

        return is_string($result) && strlen(trim($result));
    }
237872
def publish(branch, path = Dir.pwd, remote = 'origin')
      exit_status = 1
      error "no branch provided" if branch.nil?
      #remotes  = FalkorLib::Git.remotes(path)
      branches = FalkorLib::Git.list_branch(path)
      Dir.chdir(FalkorLib::Git.rootdir( path ) ) do
        if branches.include? "remotes/#{remote}/#{branch}"
          warning "the  remote branch '#{remote}/#{branch}' already exists"
        else
          info "Publish the branch '#{branch}' on the remote '#{remote}'"
          exit_status = run %(
                          git push #{remote} #{branch}:refs/heads/#{branch}
                          git fetch #{remote}
                          git branch -u #{remote}/#{branch} #{branch}
                )
        end
      end
      exit_status
    end
1046144
public static function exists($httpUri, callable $checkWith = null): bool
    {
        if ($httpUri instanceof self) {
            return $httpUri->hasDnsRecord($checkWith);
        }

        if (empty($httpUri) || !is_string($httpUri)) {
            return false;
        }

        try {
            return self::fromString($httpUri)->hasDnsRecord($checkWith);
        } catch (MalformedUri $murle) {
            return false;
        }
    }
547940
protected function validateBranch($branch)
    {
        try {
            if (!strpos($branch, '/')) {
                return false;
            }
            return $this->versionParser->normalizeBranch(
                $this->_getBranchWithoutNamespace($branch)
            );
        } catch (\Exception $e) {
            return false;
        }
    }
701174
public function cd($dir = null)
    {
        $dir = $this->_getAbsoluteRemotePath($dir);
        if (false === is_dir($dir)) {
            return $this->_trigger_error(sprintf('Unable to change remote directory to %s.', $dir));
        }
        $this->_remotepath = $dir;

        return true;
    }
901108
public function pull($remote = null, $branch = null, $rebase = false)
    {
        if ($remote instanceof Remote) {
            $remote = $remote->getName();
        }
        if ($branch instanceof Branch) {
            $branch = $branch->getName();
        }
        $this->clearAll();
        $this->addCommandName(self::GIT_PULL_COMMAND);
        if ($rebase) {
            $this->addCommandArgument('--rebase');
        }
        if (!is_null($remote)) {
            $this->addCommandSubject($remote);
        }
        if (!is_null($branch)) {
            $this->addCommandSubject2($branch);
        }

        return $this->getCommand();
    }
643328
public function delete($remote_file = null)
    {
        if (\ftp_delete($this->_stream, $remote_file)) {
            return true;
        }

        $this->error = 'Failed to delete file "'.$remote_file.'"';

        return false;
    }
378854
protected function isRequiredRepository($path, $url)
    {
        if ($this->isMultiRepository() && $this->isRepositoryCloned($path)) {
            $this->process->execute(sprintf('git config --get remote.origin.url'), $output, $path);
            return $url == trim($output);
        }
        return true; //empty directory
    }
371098
public static function cleanDir($dir, $need = true)
	{
		if (!file_exists($dir)) {
			return true;
		}

		if(is_dir($dir)){
			$files = glob($dir . DIRECTORY_SEPARATOR . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned

			foreach($files as $file) {
				static::rm($file, $need);
			}
		}

		return true;
	}
1057413
def branch(self, branch):
        '''
        
        '''

        if not branch:
            branch = self.__mbranch
        tracking = (
            ''
            if branch in self._get_branch(remotes=True).get('out') else
            '-B'
        )
        self._checkout(treeish='%s %s' % (tracking, branch))
1364415
public function dirIsEmpty($dirname)
    {
        if (!is_dir($dirname)) {
            return false;
        }
        foreach (scandir($dirname) as $file) {
            if (!in_array($file, array('.','..','.svn','.git'))) {
                return false;
            }
        }
        return true;
    }
751044
public function checkoutAllRemoteBranches($remote = 'origin')
    {
        $actualBranch = $this->getMainBranch();
        $actualBranches = $this->getBranches(true, false);
        $allBranches = $this->getBranches(true, true);
        $realBranches = array_filter(
            $allBranches,
            function (string $branch) use ($actualBranches) {
                return !in_array($branch, $actualBranches)
                && preg_match('/^remotes(.+)$/', $branch)
                && !preg_match('/^(.+)(HEAD)(.*?)$/', $branch);
            }
        );

        foreach ($realBranches as $realBranch) {
            $this->checkout(str_replace(sprintf('remotes/%s/', $remote), '', $realBranch));
        }

        $this->checkout($actualBranch);

        return $this;
    }
289014
def remote_for_branch(branch_name)
      git_call('branch -lvv').gsub('* ', '').split("\n").each do |line|
        entries = line.split(' ')
        next unless entries.first == branch_name
        # Return the remote name or nil for local branches.
        match = entries[2].match(%r(\[(.*)(\]|:)))
        return match[1].split('/').first if match
      end
      nil
    end
768230
def checkout_deploy_branch(deploy_branch, canpush=True):
    
    # Create an empty branch with .nojekyll if it doesn't already exist
    create_deploy_branch(deploy_branch, push=canpush)
    remote_branch = "doctr_remote/{}".format(deploy_branch)
    print("Checking out doctr working branch tracking", remote_branch)
    clear_working_branch()
    # If gh-pages doesn't exist the above create_deploy_branch() will create
    # it we can push, but if we can't, it won't and the --track would fail.
    if run(['git', 'rev-parse', '--verify', remote_branch], exit=False) == 0:
        extra_args = ['--track', remote_branch]
    else:
        extra_args = []
    run(['git', 'checkout', '-b', DOCTR_WORKING_BRANCH] + extra_args)
    print("Done")

    return canpush
147236
def branch_exists(self, branch):
        """"""
        try:
            git(self.gitdir, self.gitwd, "rev-parse", branch)
        except sh.ErrorReturnCode:
            return False
        return True
165128
private function exists(Collection $remote, SettingInterface $object): bool
    {
        return $remote->exists(function (int $key, SettingInterface $setting) use ($object) {
            return $setting->isEqual($object);
        });
    }
779221
public function check_dir( $need_not_empty = true )
    {
	$ok = false;

	if( is_dir( $this->_dir_path ) && is_readable( $this->_dir_path ) ) 
	{
	    $ok = true;
	    if( $need_not_empty )
	    {
		$ok = ( count( scandir( $this->_dir_path ) ) > 0 ) ? true: false;
	    }
	}
	return $ok;
    }