PHP Class Gush\Helper\GitHelper

Inheritance: extends Symfony\Component\Console\Helper\Helper
Afficher le fichier Open project: gushphp/gush Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( ProcessHelper $processHelper, GitConfigHelper $gitConfigHelper, FilesystemHelper $filesystemHelper )
add ( $path )
addNotes ( $notes, $commitHash, $ref )
branchExists ( string $branch ) : boolean
checkout ( $branchName, $createBranch = false )
clearTempBranches ( )
commit ( $message, array $options = [] )
createRemoteMergeOperation ( ) : Gush\Operation\RemoteMergeOperation
createRemotePatchOperation ( ) : Gush\Operation\RemotePatchOperation
createTempBranch ( $originalBranch )
getActiveBranchName ( string | null $defaultBranch = null ) : string
getCommitCountBetweenLocalAndBase ( $org, $branch, $sourceBranch )
getFirstCommitTitle ( string $base, string $sourceBranch ) : string
getGitDir ( ) : string
getIssueNumber ( )
getLastTagOnBranch ( string $ref = 'HEAD' ) : string
getLogBetweenCommits ( string $start, string $end ) : array[] | array Returns the log commits between two ranges (either commit or branch-name).
getName ( )
guardWorkingTreeReady ( )
isGitDir ( boolean $requireRoot = true ) : boolean Returns whether the current working dir is a Git directory.
isWorkingTreeReady ( )
listFiles ( array $options = [] ) : array
mergeBranch ( string $base, string $sourceBranch, string $commitMessage, boolean $fastForward = false ) : null | string
mergeBranchWithLog ( string $base, string $sourceBranch, string $commitMessage, string $sourceBranchLabel = null ) : string Same as mergeBranch() but appends a commits log to the merge message.
pullRemote ( $remote, $ref = null )
pushToRemote ( $remote, $ref, $setUpstream = false, $force = false )
remoteBranchExists ( string $remote, string $branch ) : boolean
remoteUpdate ( $remote = null )
reset ( $commit, $type = 'soft' )
restoreStashedBranch ( ) Tries to restore back to the original branch the user was in (before executing any command).
squashCommits ( string $base, string $branchName, boolean $ignoreMultipleAuthors = false )
stashBranchName ( ) Stashes the active branch-name.
switchBranchBase ( $branchName, $currentBase, $newBase, $newBranchName = null )
syncWithRemote ( $remote, $branchName = null )
undefinedToDefault ( string $value, string | null $default = null ) : null | string

Method Details

__construct() public méthode

public __construct ( ProcessHelper $processHelper, GitConfigHelper $gitConfigHelper, FilesystemHelper $filesystemHelper )
$processHelper ProcessHelper
$gitConfigHelper GitConfigHelper
$filesystemHelper FilesystemHelper

add() public méthode

public add ( $path )

addNotes() public méthode

public addNotes ( $notes, $commitHash, $ref )

branchExists() public méthode

public branchExists ( string $branch ) : boolean
$branch string
Résultat boolean

checkout() public méthode

public checkout ( $branchName, $createBranch = false )

clearTempBranches() public méthode

public clearTempBranches ( )

commit() public méthode

public commit ( $message, array $options = [] )
$options array

createRemoteMergeOperation() public méthode

public createRemoteMergeOperation ( ) : Gush\Operation\RemoteMergeOperation
Résultat Gush\Operation\RemoteMergeOperation

createRemotePatchOperation() public méthode

public createRemotePatchOperation ( ) : Gush\Operation\RemotePatchOperation
Résultat Gush\Operation\RemotePatchOperation

createTempBranch() public méthode

public createTempBranch ( $originalBranch )

getActiveBranchName() public méthode

public getActiveBranchName ( string | null $defaultBranch = null ) : string
$defaultBranch string | null
Résultat string The branch name

getCommitCountBetweenLocalAndBase() public méthode

public getCommitCountBetweenLocalAndBase ( $org, $branch, $sourceBranch )

getFirstCommitTitle() public méthode

public getFirstCommitTitle ( string $base, string $sourceBranch ) : string
$base string The base branch name
$sourceBranch string The source branch name
Résultat string The title of the first commit on sourceBranch off of base or an empty string in the case of an error

getGitDir() public méthode

public getGitDir ( ) : string
Résultat string

getIssueNumber() public méthode

public getIssueNumber ( )

getLastTagOnBranch() public méthode

public getLastTagOnBranch ( string $ref = 'HEAD' ) : string
$ref string commit/branch or HEAD (default is HEAD)
Résultat string The tag name

getLogBetweenCommits() public méthode

Returned result is an array like: [ ['sha' => '...', 'author' => '...', 'subject' => '...', 'message' => '...'], ] Note; - Commits are by default returned in order of oldest to newest. - sha is the full commit-hash - author is the author name and e-mail address like "My Name " - Message contains the subject followed by two new lines and the actual message-body. Or an empty array when there are no logs.
public getLogBetweenCommits ( string $start, string $end ) : array[] | array
$start string
$end string
Résultat array[] | array

getName() public méthode

public getName ( )

guardWorkingTreeReady() public méthode

isGitDir() public méthode

Returns whether the current working dir is a Git directory.
public isGitDir ( boolean $requireRoot = true ) : boolean
$requireRoot boolean Require directory is the root of the Git repository, default is true.
Résultat boolean

isWorkingTreeReady() public méthode

public isWorkingTreeReady ( )

listFiles() public méthode

public listFiles ( array $options = [] ) : array
$options array
Résultat array Files in the git repository

mergeBranch() public méthode

public mergeBranch ( string $base, string $sourceBranch, string $commitMessage, boolean $fastForward = false ) : null | string
$base string The base branch name
$sourceBranch string The source branch name
$commitMessage string Commit message to use for the merge-commit
$fastForward boolean Perform merge using fast-forward (default false)
Résultat null | string The merge-commit hash or null when fast-forward was used

mergeBranchWithLog() public méthode

Same as mergeBranch() but appends a commits log to the merge message.
public mergeBranchWithLog ( string $base, string $sourceBranch, string $commitMessage, string $sourceBranchLabel = null ) : string
$base string The base branch name
$sourceBranch string The source branch name
$commitMessage string Commit message to use for the merge-commit
$sourceBranchLabel string Actual branch (to use as replacement for the log) Else the temp-branch name is used.
Résultat string The merge-commit hash

pullRemote() public méthode

public pullRemote ( $remote, $ref = null )

pushToRemote() public méthode

public pushToRemote ( $remote, $ref, $setUpstream = false, $force = false )

remoteBranchExists() public méthode

public remoteBranchExists ( string $remote, string $branch ) : boolean
$remote string Remote name or git-repository url
$branch string
Résultat boolean

remoteUpdate() public méthode

public remoteUpdate ( $remote = null )

reset() public méthode

public reset ( $commit, $type = 'soft' )

restoreStashedBranch() public méthode

Tries to restore back to the original branch the user was in (before executing any command).

squashCommits() public méthode

public squashCommits ( string $base, string $branchName, boolean $ignoreMultipleAuthors = false )
$base string
$branchName string
$ignoreMultipleAuthors boolean Ignore there are multiple authors (ake force)

stashBranchName() public méthode

This will only stash the branch-name when no other branch was active already.
public stashBranchName ( )

switchBranchBase() public méthode

public switchBranchBase ( $branchName, $currentBase, $newBase, $newBranchName = null )

syncWithRemote() public méthode

public syncWithRemote ( $remote, $branchName = null )

undefinedToDefault() public static méthode

public static undefinedToDefault ( string $value, string | null $default = null ) : null | string
$value string
$default string | null
Résultat null | string