PHP Class Platformsh\Cli\Helper\GitHelper

Inheritance: extends Symfony\Component\Console\Helper\Helper
Afficher le fichier Open project: commerceguys/platform-cli Class Usage Examples

Protected Properties

Свойство Type Description
$repositoryDir string
$shellHelper Platformsh\Cli\Helper\ShellHelperInterface

Méthodes publiques

Méthode 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 méthode

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

branchExists() public méthode

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.
Résultat boolean

checkOut() public méthode

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
Résultat boolean

checkOutNew() public méthode

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.
Résultat boolean

cloneRepo() public méthode

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.
Résultat boolean

ensureInstalled() public méthode

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

execute() public méthode

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.
Résultat string | boolean The command output, true if there is no output, or false if the command fails.

fetch() public méthode

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
Résultat boolean

getConfig() public méthode

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.
Résultat string | false

getCurrentBranch() public méthode

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.
Résultat string | false

getMergedBranches() public méthode

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
Résultat string[]

getName() public méthode

public getName ( )

getRoot() public méthode

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
Résultat string | false

getUpstream() public méthode

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.
Résultat string | false The upstream, in the form remote/branch, or false if no upstream is found.

getVersion() public méthode

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

init() public méthode

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.
Résultat boolean

remoteBranchExists() public méthode

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
Résultat boolean

remoteRepoExists() public méthode

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

setDefaultRepositoryDir() public méthode

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

setOutput() public méthode

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

setUpstream() public méthode

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.
Résultat boolean

supportsShallowClone() public méthode

public supportsShallowClone ( ) : boolean
Résultat boolean

updateSubmodules() public méthode

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.
Résultat boolean

Property Details

$repositoryDir protected_oe property

protected string $repositoryDir
Résultat string

$shellHelper protected_oe property

protected ShellHelperInterface,Platformsh\Cli\Helper $shellHelper
Résultat Platformsh\Cli\Helper\ShellHelperInterface