PHP 클래스 VersionPress\Git\GitRepository

파일 보기 프로젝트 열기: versionpress/versionpress 1 사용 예제들

공개 메소드들

메소드 설명
__construct ( string $workingDirectoryRoot, string $tempDirectory = null, string $commitMessagePrefix = "[VP] ", string $gitBinary = "git" )
abortRevert ( ) Aborts a revert, e.g., if there was a conflict
clearWorkingDirectory ( ) : boolean Discards all modifications made to files in working directory.
commit ( CommitMessage | string $message, string $authorName, string $authorEmail ) Creates a commit.
getChildCommit ( $commitHash ) : mixed Returns child (newer) commit. Assumes there is only a single child commit.
getCommit ( $commitHash ) : Commit Gets commit object based on its hash
getDiff ( string $hash = null ) : string Returns diff for given commit.
getFileInRevision ( $path, $commitHash )
getFileModifications ( $file )
getInitialCommit ( ) : Commit Returns the initial (oldest) commit in the repo
getLastCommitHash ( string $options = "" ) : string Gets last (most recent) commit hash in the repository, or an empty string is there are no commits.
getModifiedFiles ( string $gitrevisions ) : string[] Returns list of files that were modified in given {@link http://git-scm.com/docs/gitrevisions gitrevisions}
getModifiedFilesWithStatus ( string $gitrevisions ) : array Like getModifiedFiles() but also returns the status of each file ("A" for added, "M" for modified, "D" for deleted and "R" for renamed).
getNumberOfCommits ( string $options = "", string $gitrevisions = "" ) : integer Counts number of commits
getStatus ( $array = false ) : string | array[string] Returns git status in short format, something like:
init ( ) Initializes the repository
isCleanWorkingDirectory ( ) : boolean Returns true if there are no changes to commit.
isVersioned ( ) : boolean True if the working directory is versioned
log ( string $options = "", string $gitrevisions = "" ) : Commit[] Returns an array of Commits based on {@link http://git-scm.com/docs/gitrevisions gitrevisions}
revert ( $commitHash ) : boolean Reverts a single commit. If there is a conflict, aborts the revert and returns false.
revertAll ( $commitHash ) Reverts all changes up to a given commit - performs a "rollback"
setGitProcessTimeout ( integer $gitProcessTimeout ) Changes the timeout of {@link \Symfony\Component\Process\Process}
stageAll ( string | null $path = null ) Stages all files under the given path. No path = stage all files in whole working directory.
wasCreatedAfter ( $commitHash, $afterWhichCommitHash ) : boolean Returns true if $commitHash was created after the $afterWhichCommitHash commit ("after" meaning that $commitHash is more recent commit, a child of $afterWhat). Same two commits return false.
willCommit ( ) : boolean Returns true if there is something to commit

비공개 메소드들

메소드 설명
runProcess ( $cmd ) : array Low-level helper, generally use runShellCommand()
runShellCommand ( string $command, variadic $args ) : array Run a Git command, either fully specified (e.g., 'git log') or just by the name (e.g., 'log').
runShellCommandWithErrorOutput ( string $command, string $args = '' ) : string Invokes {@see runShellCommand()} and returns its stderr output. The params are the same, only the return type is string instead of an array.
runShellCommandWithStandardOutput ( string $command, string $args = '' ) : string Invokes {@see runShellCommand()} and returns its stdout output. The params are the same, only the return type is string instead of an array.

메소드 상세

__construct() 공개 메소드

public __construct ( string $workingDirectoryRoot, string $tempDirectory = null, string $commitMessagePrefix = "[VP] ", string $gitBinary = "git" )
$workingDirectoryRoot string Filesystem path to working directory root (where the .git folder resides)
$tempDirectory string Directory used for commit message temp file. See commit().
$commitMessagePrefix string Standard prefix applied to all commit messages
$gitBinary string Git binary to use

abortRevert() 공개 메소드

Aborts a revert, e.g., if there was a conflict
public abortRevert ( )

clearWorkingDirectory() 공개 메소드

Also deletes untracked files.
public clearWorkingDirectory ( ) : boolean
리턴 boolean

commit() 공개 메소드

Uses a temporary file to construct the commit message because on Windows, multi-line commit message cannot be created on CLI and it's generally a more flexible solution (very long commit messages, etc.).
public commit ( CommitMessage | string $message, string $authorName, string $authorEmail )
$message CommitMessage | string
$authorName string
$authorEmail string

getChildCommit() 공개 메소드

Returns child (newer) commit. Assumes there is only a single child commit.
public getChildCommit ( $commitHash ) : mixed
$commitHash
리턴 mixed

getCommit() 공개 메소드

Gets commit object based on its hash
public getCommit ( $commitHash ) : Commit
$commitHash
리턴 Commit

getDiff() 공개 메소드

If null, returns diff of working directory and HEAD
public getDiff ( string $hash = null ) : string
$hash string
리턴 string

getFileInRevision() 공개 메소드

public getFileInRevision ( $path, $commitHash )

getFileModifications() 공개 메소드

public getFileModifications ( $file )

getInitialCommit() 공개 메소드

Returns the initial (oldest) commit in the repo
public getInitialCommit ( ) : Commit
리턴 Commit

getLastCommitHash() 공개 메소드

Gets last (most recent) commit hash in the repository, or an empty string is there are no commits.
public getLastCommitHash ( string $options = "" ) : string
$options string Options passed to git log
리턴 string Empty string or SHA1

getModifiedFiles() 공개 메소드

Returns list of files that were modified in given {@link http://git-scm.com/docs/gitrevisions gitrevisions}
public getModifiedFiles ( string $gitrevisions ) : string[]
$gitrevisions string
리턴 string[]

getModifiedFilesWithStatus() 공개 메소드

Like getModifiedFiles() but also returns the status of each file ("A" for added, "M" for modified, "D" for deleted and "R" for renamed).
public getModifiedFilesWithStatus ( string $gitrevisions ) : array
$gitrevisions string See gitrevisions
리턴 array Array of things like `array("status" => "M", "path" => "wp-content/vpdb/something.ini" )`

getNumberOfCommits() 공개 메소드

Counts number of commits
public getNumberOfCommits ( string $options = "", string $gitrevisions = "" ) : integer
$options string Options passed to git log
$gitrevisions string Empty by default, i.e., calling full 'git log'
리턴 integer

getStatus() 공개 메소드

A path1.txt M path2.txt Clean working directory returns an empty string.
public getStatus ( $array = false ) : string | array[string]
$array bool Return result as array
리턴 string | array[string]

init() 공개 메소드

Initializes the repository
public init ( )

isCleanWorkingDirectory() 공개 메소드

Returns true if there are no changes to commit.

isVersioned() 공개 메소드

True if the working directory is versioned
public isVersioned ( ) : boolean
리턴 boolean

log() 공개 메소드

Returns an array of Commits based on {@link http://git-scm.com/docs/gitrevisions gitrevisions}
public log ( string $options = "", string $gitrevisions = "" ) : Commit[]
$options string Options passed to git log
$gitrevisions string Empty by default, i.e., calling full 'git log'
리턴 Commit[]

revert() 공개 메소드

Reverts a single commit. If there is a conflict, aborts the revert and returns false.
public revert ( $commitHash ) : boolean
$commitHash
리턴 boolean True if it succeeded, false if there was a conflict

revertAll() 공개 메소드

Reverts all changes up to a given commit - performs a "rollback"
public revertAll ( $commitHash )
$commitHash

setGitProcessTimeout() 공개 메소드

Changes the timeout of {@link \Symfony\Component\Process\Process}
public setGitProcessTimeout ( integer $gitProcessTimeout )
$gitProcessTimeout integer

stageAll() 공개 메소드

Stages all files under the given path. No path = stage all files in whole working directory.
public stageAll ( string | null $path = null )
$path string | null Null (the default) means the whole working directory

wasCreatedAfter() 공개 메소드

Returns true if $commitHash was created after the $afterWhichCommitHash commit ("after" meaning that $commitHash is more recent commit, a child of $afterWhat). Same two commits return false.
public wasCreatedAfter ( $commitHash, $afterWhichCommitHash ) : boolean
$commitHash
$afterWhichCommitHash
리턴 boolean

willCommit() 공개 메소드

Returns true if there is something to commit
public willCommit ( ) : boolean
리턴 boolean