PHP Class Platformsh\Cli\Helper\GitHelper

Inheritance: extends Symfony\Component\Console\Helper\Helper
Exibir arquivo Open project: commerceguys/platform-cli Class Usage Examples

Protected Properties

Property Type Description
$repositoryDir string
$shellHelper Platformsh\Cli\Helper\ShellHelperInterface

Public Methods

Method Description
__construct ( Platformsh\Cli\Helper\ShellHelperInterface $shellHelper = null ) Constructor.
branchExists ( string $branchName, string $dir = null, boolean $mustRun = false ) : boolean Check whether a branch exists.
checkOut ( string $name, string | null $dir = null, boolean $mustRun = false, boolean $quiet = false ) : boolean Check out a branch.
checkOutNew ( string $name, string | null $parent = null, string | null $upstream = null, string | null $dir = null, boolean $mustRun = false ) : boolean Create a new branch and check it out.
cloneRepo ( string $url, string $destination = null, array $args = [], boolean $mustRun = false ) : boolean Clone a repository.
ensureInstalled ( ) Ensure that the Git CLI is installed.
execute ( array $args, string | false $dir = null, boolean $mustRun = false, boolean $quiet = true ) : string | boolean Execute a Git command.
fetch ( string $remote, string | null $branch = null, string | null $dir = null, boolean $mustRun = false ) : boolean Fetch from the Git remote.
getConfig ( string $key, string | null $dir = null, boolean $mustRun = false ) : string | false Read a configuration item.
getCurrentBranch ( string $dir = null, boolean $mustRun = false ) : string | false Get the current branch name.
getMergedBranches ( string $ref = 'HEAD', boolean $remote = false, null $dir = null, boolean $mustRun = false ) : string[] Get a list of branches merged with a specific ref.
getName ( )
getRoot ( string | null $dir = null, boolean $mustRun = false ) : string | false Find the root of a directory in a Git repository.
getUpstream ( string $branch = null, string | null $dir = null, boolean $mustRun = false ) : string | false Get the upstream for a branch.
getVersion ( ) : string | false Get the installed version of the Git CLI.
init ( string $dir, boolean $mustRun = false ) : boolean Create a Git repository in a directory.
remoteBranchExists ( string $remote, string $branchName, null $dir = null, boolean $mustRun = false ) : boolean Check whether a branch exists on a remote.
remoteRepoExists ( string $url ) : boolean Check whether a remote repository exists.
setDefaultRepositoryDir ( string $dir ) Set the repository directory.
setOutput ( Symfony\Component\Console\Output\OutputInterface $output )
setUpstream ( string | false $upstream, string | null $dir = null, boolean $mustRun = false ) : boolean Set the upstream for the current branch.
supportsShallowClone ( ) : boolean
updateSubmodules ( boolean $recursive = false, string | null $dir = null, boolean $mustRun = false ) : boolean Update and/or initialize submodules.

Method Details

__construct() public method

Constructor.
public __construct ( Platformsh\Cli\Helper\ShellHelperInterface $shellHelper = null )
$shellHelper Platformsh\Cli\Helper\ShellHelperInterface

branchExists() public method

Check whether a branch exists.
public branchExists ( string $branchName, string $dir = null, boolean $mustRun = false ) : boolean
$branchName string The branch name.
$dir string The path to a Git repository.
$mustRun boolean Enable exceptions if the Git command fails.
return boolean

checkOut() public method

Check out a branch.
public checkOut ( string $name, string | null $dir = null, boolean $mustRun = false, boolean $quiet = false ) : boolean
$name string
$dir string | null The path to a Git repository.
$mustRun boolean Enable exceptions if the Git command fails.
$quiet boolean
return boolean

checkOutNew() public method

Create a new branch and check it out.
public checkOutNew ( string $name, string | null $parent = null, string | null $upstream = null, string | null $dir = null, boolean $mustRun = false ) : boolean
$name string
$parent string | null
$upstream string | null
$dir string | null The path to a Git repository.
$mustRun boolean Enable exceptions if the Git command fails.
return boolean

cloneRepo() public method

A ProcessFailedException will be thrown if the command fails.
public cloneRepo ( string $url, string $destination = null, array $args = [], boolean $mustRun = false ) : boolean
$url string The Git repository URL.
$destination string A directory name to clone into.
$args array Extra arguments for the Git command.
$mustRun boolean Enable exceptions if the Git command fails.
return boolean

ensureInstalled() public method

Ensure that the Git CLI is installed.
public ensureInstalled ( )

execute() public method

Execute a Git command.
public execute ( array $args, string | false $dir = null, boolean $mustRun = false, boolean $quiet = true ) : string | boolean
$args array Command arguments (everything after 'git').
$dir string | false The path to a Git repository. Set to false if the command should not run inside a repository.
$mustRun boolean Enable exceptions if the Git command fails.
$quiet boolean Suppress command output.
return string | boolean The command output, true if there is no output, or false if the command fails.

fetch() public method

Fetch from the Git remote.
public fetch ( string $remote, string | null $branch = null, string | null $dir = null, boolean $mustRun = false ) : boolean
$remote string
$branch string | null
$dir string | null
$mustRun boolean
return boolean

getConfig() public method

Read a configuration item.
public getConfig ( string $key, string | null $dir = null, boolean $mustRun = false ) : string | false
$key string A Git configuration key.
$dir string | null The path to a Git repository.
$mustRun boolean Enable exceptions if the Git command fails.
return string | false

getCurrentBranch() public method

Get the current branch name.
public getCurrentBranch ( string $dir = null, boolean $mustRun = false ) : string | false
$dir string The path to a Git repository.
$mustRun boolean Enable exceptions if the Git command fails.
return string | false

getMergedBranches() public method

Get a list of branches merged with a specific ref.
public getMergedBranches ( string $ref = 'HEAD', boolean $remote = false, null $dir = null, boolean $mustRun = false ) : string[]
$ref string
$remote boolean
$dir null
$mustRun boolean
return string[]

getName() public method

public getName ( )

getRoot() public method

Find the root of a directory in a Git repository.
public getRoot ( string | null $dir = null, boolean $mustRun = false ) : string | false
$dir string | null
$mustRun boolean
return string | false

getUpstream() public method

Get the upstream for a branch.
public getUpstream ( string $branch = null, string | null $dir = null, boolean $mustRun = false ) : string | false
$branch string The name of the branch to get the upstream for. Defaults to the current branch.
$dir string | null The path to a Git repository.
$mustRun boolean Enable exceptions if the Git command fails.
return string | false The upstream, in the form remote/branch, or false if no upstream is found.

getVersion() public method

Get the installed version of the Git CLI.
public getVersion ( ) : string | false
return string | false The version number, or false on failure.

init() public method

Create a Git repository in a directory.
public init ( string $dir, boolean $mustRun = false ) : boolean
$dir string
$mustRun boolean Enable exceptions if the Git command fails.
return boolean

remoteBranchExists() public method

Check whether a branch exists on a remote.
public remoteBranchExists ( string $remote, string $branchName, null $dir = null, boolean $mustRun = false ) : boolean
$remote string
$branchName string
$dir null
$mustRun boolean
return boolean

remoteRepoExists() public method

Check whether a remote repository exists.
public remoteRepoExists ( string $url ) : boolean
$url string
return boolean

setDefaultRepositoryDir() public method

The default is the current working directory.
public setDefaultRepositoryDir ( string $dir )
$dir string The path to a Git repository.

setOutput() public method

public setOutput ( Symfony\Component\Console\Output\OutputInterface $output )
$output Symfony\Component\Console\Output\OutputInterface

setUpstream() public method

Set the upstream for the current branch.
public setUpstream ( string | false $upstream, string | null $dir = null, boolean $mustRun = false ) : boolean
$upstream string | false The upstream name, or false to unset the upstream.
$dir string | null The path to a Git repository.
$mustRun boolean Enable exceptions if the Git command fails.
return boolean

supportsShallowClone() public method

public supportsShallowClone ( ) : boolean
return boolean

updateSubmodules() public method

Update and/or initialize submodules.
public updateSubmodules ( boolean $recursive = false, string | null $dir = null, boolean $mustRun = false ) : boolean
$recursive boolean Whether to recurse into nested submodules.
$dir string | null The path to a Git repository.
$mustRun boolean Enable exceptions if the Git command fails.
return boolean

Property Details

$repositoryDir protected_oe property

protected string $repositoryDir
return string

$shellHelper protected_oe property

protected ShellHelperInterface,Platformsh\Cli\Helper $shellHelper
return Platformsh\Cli\Helper\ShellHelperInterface