Repository
MMO\git\helpers · 1 symbole · générée le 27 Oct 2026
Repository
Repository.php:30A local git repository, driven by the git command line.
- Espace de noms
MMO\git\helpers- Étend
- aEntry
- Implémente
- iSerializable
- Voir
Processand throws aneRuntimeon a non-zero exit code, so a failing git command is an exception rather than a string nobody reads. The defaults (bin,sudo,timeout) come from the,Gitmodule and can be overridden per instance.
Index
| ahead | ||
| behind | ||
| bin | ||
| branch | ||
| entries | ||
| id | ||
| runAsSudo | ||
| timeout | ||
| upstream | ||
| valid | ||
| add($file, $option) | Runs a git add call. | |
| addTag($tag, $message) | Add an annotated tag at the current position. | |
| archive($ref, $folder, $options) | Export a ref's tree into a folder: tracked files only, no .git, nothing the working tree happens to carry. | |
| assertValid() | ||
| attribute($diff, $paths) | Say which commit of a range made each change of its diff (DiffLine::$commit): on an added line, the commit that wrote it as it reads at the end of the range; on a removed line, the commit that… | |
| blame($cmd, $boundary) | Read git blame --line-porcelain: each line's block starts <hash> <line in the commit> <line in the file> and ends with the line itself, after a tab. | |
| checkout($branch, $create) | Runs a git checkout call. | |
| checkoutAndPull($branch) | Checkout a branch, then pull it when it is behind its upstream. | |
| children($from, $to) | ||
| clearEntries() | ||
| commit($message, $options) | Runs a git commit call. | |
| createBranch($branch) | ||
| deleteBranch($branch, $force) | ||
| diff($from, $to, $paths, $context, $ignoreWhitespace) | What changed between two revisions, file by file, line by line. | |
| diffCommit($commit, $paths, $context, $ignoreWhitespace) | What one commit changed: diff from its first parent, or from nothing for the first commit of the history. | |
| Escape($arg) static | Escape one argument for the shell. | |
| exec($cmd, $throwOnExitCode, $exitCode) | Run a git command in the repository folder. | |
| execTrim($cmd, $throwOnExitCode, $exitCode) | ||
| fetch($opts) | ||
| getAhead() | ||
| getBehind() | ||
| getBranch() | The current branch, or -- on a detached HEAD, which has no branch -- the short commit hash. | |
| getChangedEntries() | ||
| getCommit($format) | ||
| getCommitHash($short) | ||
| getCommitVersion() | A version for the current commit, derived from the most recent tag. | |
| getEntriesStatus() | ||
| getEntriesStatusText($sep) | ||
| getEntry($relativeFilename) | ||
| getFetchRemotes() | ||
| getModuleStatus() | ||
| getModuleStatusText($sep) | ||
| getPushRemotes() | ||
| getRemoteName($url, $fetch) | The name of the remote serving $url. | |
| getRemotes($direction) | The configured remotes. | |
| getRevisionCount($branch1, $branch2) | How many commits $branch2 has that $branch1 does not. | |
| getUpstream() | ||
| getUpstreamOf($branch) | The remote-tracking branch a local branch follows, e.g. | |
| hasChanges() | ||
| hasDiff($filter, $files, $ref) | Check whether there are differences against $ref. | |
| init() | ||
| isClean() | ||
| isDetached() | ||
| isValid() | ||
| isValidRemote($url) | ||
| list() | Every tracked entry, recursing into the submodules. | |
| listBranches($incLocal, $incRemote) | Runs a git branch call. | |
| listModules() | The submodules declared by this repository. | |
| listTags($pattern) | List the repository tags, most recent version first. | |
| log($range, $paths, $max) | The commits of a range, the newest first, as git log lists them. | |
| makeEntry($file, $status, $sub, $origin) | Build (or refresh) one entry of update, choosing File or Module from the <sub> field git reported. | |
| merge($branch, $options) | Runs a git merge call. | |
| mtime($filename, $options) | ||
| pull($remote, $branch, $options) | Pull a specific branch from a remote. | |
| push($remote, $branch, $options) | Push a specific branch (or all branches) to a remote. | |
| pushMasterVersion($masterBranch, $where, $defaultVersion) | Merge the current branch into the master branch and tag the version. | |
| realCommand($cmd) | ||
| remove($file, $option) | ||
| resolve($ref) | Resolve any commit-ish (a branch, a tag, HEAD~2, ...) to its full hash. | |
| restoreTime($filename, $options) | ||
| serialize($path, $serializer) | Only the folder and the status are persisted: everything else (update's entries, the branch, the ahead/behind counters) is a cache of what git said at one moment, and is re-read on the next @s… | |
| setFolder($folder) | ||
| show($revision, $filename) | Show the content of a file from another branch/revision. | |
| status() | ||
| tagVersion($message, $where, $inc, $default) | Tag the current commit with the next version after the most recent v* tag. | |
| test($cmd) | ||
| unserialize($data, $path, $instances) | ||
| update() | Read git status into this repository's flags and entries. | |
| __construct($filename, $status, $origin) |
Propriétés10
ahead
- Type
- int
behind
- Type
- int
bin
- Type
- string
branch
entries
- Type
- array
id
runAsSudo
- Type
- bool
timeout
upstream
valid
- Type
- bool
Méthodes69
add($file, $option)
Repository.php:396Runs a git add call.
addTag($tag, $message)
Repository.php:883Add an annotated tag at the current position.
archive($ref, $folder, $options)
Repository.php:618Export a ref's tree into a folder: tracked files only, no .git, nothing the working tree happens to carry. This is what a release must be packaged from -- BuildTask.
assertValid()
Repository.php:95| retourne | void |
attribute($diff, $paths)
Repository.php:543Say which commit of a range made each change of its diff (DiffLine::$commit): on an added line, the commit that wrote it as it reads at the end of the range; on a removed line, the commit that removed it.
| $diff | Diff | made by diff between two revisions, the first an ancestor of the second |
| $paths = null | null | array | only these files of it (by their new or old path); null: all of them |
| retourne | Diff | $diff, its changed lines attributed |
| lève | when $diff is against the working tree, which has no commit to name |
blame($cmd, $boundary)
Repository.php:581Read git blame --line-porcelain: each line's block starts <hash> <line in the commit> <line in the file> and ends with the line itself, after a tab.
checkout($branch, $create)
Repository.php:695Runs a git checkout call.
checkoutAndPull($branch)
Repository.php:710Checkout a branch, then pull it when it is behind its upstream.
children($from, $to)
Repository.php:599clearEntries()
Repository.php:190| retourne | void |
commit($message, $options)
Repository.php:450Runs a git commit call.
createBranch($branch)
Repository.php:657deleteBranch($branch, $force)
Repository.php:662diff($from, $to, $paths, $context, $ignoreWhitespace)
Repository.php:501What changed between two revisions, file by file, line by line.
| $from | string | the old revision (a hash, a branch, a tag, HEAD~2...) |
| $to = null | null | string | the new revision; null: the working tree |
| $paths = [] | array | only these paths (files or folders, from the repository's root); none: every path |
| $context = 3 | int | how many unchanged lines git keeps around each change |
| $ignoreWhitespace = false | bool | leave out changes in whitespace alone (-w) |
| retourne | Diff | |
| lève | when a revision does not exist |
diffCommit($commit, $paths, $context, $ignoreWhitespace)
Repository.php:520What one commit changed: diff from its first parent, or from nothing for the first commit of the history.
| $commit | string | |
| $paths = [] | array | diff |
| $context = 3 | int | diff |
| $ignoreWhitespace = false | bool | diff |
| retourne | Diff | from the parent's hash (or the empty tree's) to $commit |
Escape($arg)
staticRepository.php:102Escape one argument for the shell. Use it for anything that is not a literal in the source.
exec($cmd, $throwOnExitCode, $exitCode)
Repository.php:118Run a git command in the repository folder.
execTrim($cmd, $throwOnExitCode, $exitCode)
Repository.php:132fetch($opts)
Repository.php:383getAhead()
Repository.php:144| retourne | int |
getBehind()
Repository.php:148| retourne | int |
getBranch()
Repository.php:643The current branch, or -- on a detached HEAD, which has no branch -- the short commit hash.
| retourne | string |
getChangedEntries()
Repository.php:182getCommit($format)
Repository.php:767getCommitHash($short)
Repository.php:751getCommitVersion()
Repository.php:791A version for the current commit, derived from the most recent tag.
| retourne | string |
getEntriesStatus()
Repository.php:160| retourne | int |
getEntriesStatusText($sep)
Repository.php:156getEntry($relativeFilename)
Repository.php:186getFetchRemotes()
Repository.php:849| retourne | array | {name: url} |
getModuleStatus()
Repository.php:168| retourne | int |
getModuleStatusText($sep)
Repository.php:164getPushRemotes()
Repository.php:854| retourne | array | {name: url} |
getRemoteName($url, $fetch)
Repository.php:868The name of the remote serving $url.
getRemotes($direction)
Repository.php:837The configured remotes.
getRevisionCount($branch1, $branch2)
Repository.php:805How many commits $branch2 has that $branch1 does not.
getUpstream()
Repository.php:152getUpstreamOf($branch)
Repository.php:730The remote-tracking branch a local branch follows, e.g. origin/main.
hasChanges()
Repository.php:172| retourne | bool |
hasDiff($filter, $files, $ref)
Repository.php:471Check whether there are differences against $ref.
| $filter = null | null | string | Select only files that are Added (A), Copied (C), Deleted (D), Modified (M), Renamed (R), have their type (i.e. regular file, symlink, submodule, ...) changed (T), are Unmerged (U), are Unknown (X), or have had their pairing Broken (B). Any combination of the filter characters (including none) can be used |
| $files = '' | string | list of files to check. If empty, checks for any change |
| $ref = 'HEAD' | string | if @tag, replaced by the most recent tag |
| retourne | bool |
init()
Repository.php:366| retourne | void |
isClean()
Repository.php:177| retourne | bool | true when the working tree has nothing uncommitted -- what a release must build from. |
isDetached()
Repository.php:652| retourne | bool |
isValid()
Repository.php:91| retourne | bool |
isValidRemote($url)
Repository.php:858list()
Repository.php:200Every tracked entry, recursing into the submodules.
| retourne | array | aEntry> keyed by the path relative to this repository |
listBranches($incLocal, $incRemote)
Repository.php:673Runs a git branch call.
listModules()
Repository.php:224The submodules declared by this repository.
| retourne | array | Module> keyed by the path relative to this repository |
listTags($pattern)
Repository.php:893List the repository tags, most recent version first.
log($range, $paths, $max)
Repository.php:822The commits of a range, the newest first, as git log lists them.
| $range = 'HEAD' | string | what git log takes: A..B (the commits of B that A does not have), a branch, a hash... |
| $paths = [] | array | only the commits that touch these paths; none: every commit |
| $max = null | null | int | at most that many commits; null: all of them |
| retourne | array | |
| lève | when the range does not resolve |
makeEntry($file, $status, $sub, $origin)
Repository.php:347Build (or refresh) one entry of update, choosing File or Module from the <sub> field git reported.
merge($branch, $options)
Repository.php:743Runs a git merge call.
mtime($filename, $options)
Repository.php:625pull($remote, $branch, $options)
Repository.php:436Pull a specific branch from a remote.
push($remote, $branch, $options)
Repository.php:417Push a specific branch (or all branches) to a remote.
pushMasterVersion($masterBranch, $where, $defaultVersion)
Repository.php:944Merge the current branch into the master branch and tag the version.
realCommand($cmd)
Repository.php:106remove($file, $option)
Repository.php:401resolve($ref)
Repository.php:762Resolve any commit-ish (a branch, a tag, HEAD~2, ...) to its full hash.
restoreTime($filename, $options)
Repository.php:631serialize($path, $serializer)
Repository.php:72Only the folder and the status are persisted: everything else (update's entries, the branch, the ahead/behind counters) is a cache of what git said at one moment, and is re-read on the next update.
setFolder($folder)
Repository.php:84show($revision, $filename)
Repository.php:932Show the content of a file from another branch/revision.
| $revision | string | branch or revision/ref |
| $filename | string | relative to the repository root |
| retourne | string | the content of the file |
status()
Repository.php:378| retourne | string |
tagVersion($message, $where, $inc, $default)
Repository.php:912Tag the current commit with the next version after the most recent v* tag.
test($cmd)
Repository.php:137unserialize($data, $path, $instances)
Repository.php:78update()
Repository.php:246Read git status into this repository's flags and entries.
| retourne | static |
__construct($filename, $status, $origin)
Repository.php:51Membres hérités (44)
| Constantes | Déclaré par | Description | |
|---|---|---|---|
CAN_BE_ADDED | iEntry | ||
CAN_BE_COMMITED | iEntry | ||
COMMIT_CHANGED | iEntry | ||
ENTRY_STATUS | iEntry | ||
INDEX_ADDED | iEntry | ||
INDEX_COPIED | iEntry | ||
INDEX_DELETED | iEntry | ||
INDEX_IGNORED | iEntry | ||
INDEX_MODIFIED | iEntry | ||
INDEX_RENAMED | iEntry | ||
INDEX_UNMERGED | iEntry | ||
INDEX_UNTRACKED | iEntry | ||
MODULE_STATUS | iEntry | ||
TRACKED_CHANGES | iEntry | ||
UNKNOWN_ERROR | iEntry | ||
UNTRACKED_CHANGES | iEntry | ||
WORKTREE_ADDED | iEntry | ||
WORKTREE_COPIED | iEntry | ||
WORKTREE_DELETED | iEntry | ||
WORKTREE_IGNORED | iEntry | ||
WORKTREE_MODIFIED | iEntry | ||
WORKTREE_RENAMED | iEntry | ||
WORKTREE_UNMERGED | iEntry | ||
WORKTREE_UNTRACKED | iEntry |
| Méthodes | Déclaré par | Description | |
|---|---|---|---|
addStatus($flags) | aEntry | ||
clearStatus($flags) | aEntry | ||
debugName() | aEntry | ||
getFilename() | aEntry | ||
getOrigin() | aEntry | ||
getParent() | aEntry | ||
getStatus() | aEntry | ||
getStatusText($sep) | aEntry | ||
relativeFilename() | aEntry | The filename relative to the repository this entry belongs to. | |
setOrigin($origin) | aEntry | ||
setParent($parent) | aEntry | ||
setStatus($flags, $origin) | aEntry | Replace the status flags, and -- because git reports a rename's previous path alongside its status -- optionally the origin in the same call. | |
StatusFlags($flags) | aEntry | Read the two-character <XY> field of a git status --porcelain=2 entry. | |
StatusModuleFlags($flags) | aEntry | Read the four-character <sub> field of a git status --porcelain=2 entry (N... for a plain file, S<c><m><u> for a submodule). | |
StatusText($status, $sep) | aEntry | Convert git status constants to text. |