PHP Class Gush\Helper\GitHelper

Inheritance: extends Symfony\Component\Console\Helper\Helper
Datei anzeigen Open project: gushphp/gush Class Usage Examples

Public Methods

Method 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 method

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

add() public method

public add ( $path )

addNotes() public method

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

branchExists() public method

public branchExists ( string $branch ) : boolean
$branch string
return boolean

checkout() public method

public checkout ( $branchName, $createBranch = false )

clearTempBranches() public method

public clearTempBranches ( )

commit() public method

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

createRemoteMergeOperation() public method

public createRemoteMergeOperation ( ) : Gush\Operation\RemoteMergeOperation
return Gush\Operation\RemoteMergeOperation

createRemotePatchOperation() public method

public createRemotePatchOperation ( ) : Gush\Operation\RemotePatchOperation
return Gush\Operation\RemotePatchOperation

createTempBranch() public method

public createTempBranch ( $originalBranch )

getActiveBranchName() public method

public getActiveBranchName ( string | null $defaultBranch = null ) : string
$defaultBranch string | null
return string The branch name

getCommitCountBetweenLocalAndBase() public method

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

getFirstCommitTitle() public method

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

getGitDir() public method

public getGitDir ( ) : string
return string

getIssueNumber() public method

public getIssueNumber ( )

getLastTagOnBranch() public method

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

getLogBetweenCommits() public method

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
return array[] | array

getName() public method

public getName ( )

guardWorkingTreeReady() public method

isGitDir() public method

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.
return boolean

isWorkingTreeReady() public method

public isWorkingTreeReady ( )

listFiles() public method

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

mergeBranch() public method

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)
return null | string The merge-commit hash or null when fast-forward was used

mergeBranchWithLog() public method

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.
return string The merge-commit hash

pullRemote() public method

public pullRemote ( $remote, $ref = null )

pushToRemote() public method

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

remoteBranchExists() public method

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

remoteUpdate() public method

public remoteUpdate ( $remote = null )

reset() public method

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

restoreStashedBranch() public method

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

squashCommits() public method

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

stashBranchName() public method

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

switchBranchBase() public method

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

syncWithRemote() public method

public syncWithRemote ( $remote, $branchName = null )

undefinedToDefault() public static method

public static undefinedToDefault ( string $value, string | null $default = null ) : null | string
$value string
$default string | null
return null | string