PHP Класс Gush\Helper\GitHelper

Наследование: extends Symfony\Component\Console\Helper\Helper
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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

Описание методов

__construct() публичный Метод

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

add() публичный Метод

public add ( $path )

addNotes() публичный Метод

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

branchExists() публичный Метод

public branchExists ( string $branch ) : boolean
$branch string
Результат boolean

checkout() публичный Метод

public checkout ( $branchName, $createBranch = false )

clearTempBranches() публичный Метод

public clearTempBranches ( )

commit() публичный Метод

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

createRemoteMergeOperation() публичный Метод

public createRemoteMergeOperation ( ) : Gush\Operation\RemoteMergeOperation
Результат Gush\Operation\RemoteMergeOperation

createRemotePatchOperation() публичный Метод

public createRemotePatchOperation ( ) : Gush\Operation\RemotePatchOperation
Результат Gush\Operation\RemotePatchOperation

createTempBranch() публичный Метод

public createTempBranch ( $originalBranch )

getActiveBranchName() публичный Метод

public getActiveBranchName ( string | null $defaultBranch = null ) : string
$defaultBranch string | null
Результат string The branch name

getCommitCountBetweenLocalAndBase() публичный Метод

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

getFirstCommitTitle() публичный Метод

public getFirstCommitTitle ( string $base, string $sourceBranch ) : string
$base string The base branch name
$sourceBranch string The source branch name
Результат string The title of the first commit on sourceBranch off of base or an empty string in the case of an error

getGitDir() публичный Метод

public getGitDir ( ) : string
Результат string

getIssueNumber() публичный Метод

public getIssueNumber ( )

getLastTagOnBranch() публичный Метод

public getLastTagOnBranch ( string $ref = 'HEAD' ) : string
$ref string commit/branch or HEAD (default is HEAD)
Результат string The tag name

getLogBetweenCommits() публичный Метод

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
Результат array[] | array

getName() публичный Метод

public getName ( )

guardWorkingTreeReady() публичный Метод

isGitDir() публичный Метод

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.
Результат boolean

isWorkingTreeReady() публичный Метод

public isWorkingTreeReady ( )

listFiles() публичный Метод

public listFiles ( array $options = [] ) : array
$options array
Результат array Files in the git repository

mergeBranch() публичный Метод

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)
Результат null | string The merge-commit hash or null when fast-forward was used

mergeBranchWithLog() публичный Метод

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.
Результат string The merge-commit hash

pullRemote() публичный Метод

public pullRemote ( $remote, $ref = null )

pushToRemote() публичный Метод

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

remoteBranchExists() публичный Метод

public remoteBranchExists ( string $remote, string $branch ) : boolean
$remote string Remote name or git-repository url
$branch string
Результат boolean

remoteUpdate() публичный Метод

public remoteUpdate ( $remote = null )

reset() публичный Метод

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

restoreStashedBranch() публичный Метод

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

squashCommits() публичный Метод

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

stashBranchName() публичный Метод

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

switchBranchBase() публичный Метод

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

syncWithRemote() публичный Метод

public syncWithRemote ( $remote, $branchName = null )

undefinedToDefault() публичный статический Метод

public static undefinedToDefault ( string $value, string | null $default = null ) : null | string
$value string
$default string | null
Результат null | string