Repository
MMO\git\helpers · 1 symbol · generated 5 Oct 2026
Repository
Repository.php:30A local git repository, driven by the git command line.
- Namespace
MMO\git\helpers- Extends
- aEntry
- Implements
- iSerializable
- See
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() | ||
| checkout($branch, $create) | Runs a git checkout call. | |
| checkoutAndPull($branch) | Checkout a branch, then pull it when it is behind its upstream. | |
| clearEntries() | ||
| commit($message, $options) | Runs a git commit call. | |
| createBranch($branch) | ||
| deleteBranch($branch, $force) | ||
| 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. | |
| 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) |
Properties10
ahead
- Type
- int
behind
- Type
- int
bin
- Type
- string
branch
entries
- Type
- array
id
runAsSudo
- Type
- bool
timeout
upstream
valid
- Type
- bool
Methods63
add($file, $option)
Repository.php:396Runs a git add call.
addTag($tag, $message)
Repository.php:739Add an annotated tag at the current position.
archive($ref, $folder, $options)
Repository.php:492Export 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| returns | void |
checkout($branch, $create)
Repository.php:569Runs a git checkout call.
checkoutAndPull($branch)
Repository.php:584Checkout a branch, then pull it when it is behind its upstream.
clearEntries()
Repository.php:190| returns | void |
commit($message, $options)
Repository.php:450Runs a git commit call.
createBranch($branch)
Repository.php:531deleteBranch($branch, $force)
Repository.php:536Escape($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| returns | int |
getBehind()
Repository.php:148| returns | int |
getBranch()
Repository.php:517The current branch, or -- on a detached HEAD, which has no branch -- the short commit hash.
| returns | string |
getChangedEntries()
Repository.php:182getCommit($format)
Repository.php:641getCommitHash($short)
Repository.php:625getCommitVersion()
Repository.php:665A version for the current commit, derived from the most recent tag.
| returns | string |
getEntriesStatus()
Repository.php:160| returns | int |
getEntriesStatusText($sep)
Repository.php:156getEntry($relativeFilename)
Repository.php:186getFetchRemotes()
Repository.php:705| returns | array | {name: url} |
getModuleStatus()
Repository.php:168| returns | int |
getModuleStatusText($sep)
Repository.php:164getPushRemotes()
Repository.php:710| returns | array | {name: url} |
getRemoteName($url, $fetch)
Repository.php:724The name of the remote serving $url.
getRemotes($direction)
Repository.php:693The configured remotes.
getRevisionCount($branch1, $branch2)
Repository.php:679How many commits $branch2 has that $branch1 does not.
getUpstream()
Repository.php:152getUpstreamOf($branch)
Repository.php:604The remote-tracking branch a local branch follows, e.g. origin/main.
hasChanges()
Repository.php:172| returns | 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 |
| returns | bool |
init()
Repository.php:366| returns | void |
isClean()
Repository.php:177| returns | bool | true when the working tree has nothing uncommitted -- what a release must build from. |
isDetached()
Repository.php:526| returns | bool |
isValid()
Repository.php:91| returns | bool |
isValidRemote($url)
Repository.php:714list()
Repository.php:200Every tracked entry, recursing into the submodules.
| returns | array | aEntry> keyed by the path relative to this repository |
listBranches($incLocal, $incRemote)
Repository.php:547Runs a git branch call.
listModules()
Repository.php:224The submodules declared by this repository.
| returns | array | Module> keyed by the path relative to this repository |
listTags($pattern)
Repository.php:749List the repository tags, most recent version first.
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:617Runs a git merge call.
mtime($filename, $options)
Repository.php:499pull($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:800Merge the current branch into the master branch and tag the version.
realCommand($cmd)
Repository.php:106remove($file, $option)
Repository.php:401resolve($ref)
Repository.php:636Resolve any commit-ish (a branch, a tag, HEAD~2, ...) to its full hash.
restoreTime($filename, $options)
Repository.php:505serialize($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:788Show the content of a file from another branch/revision.
| $revision | string | branch or revision/ref |
| $filename | string | relative to the repository root |
| returns | string | the content of the file |
status()
Repository.php:378| returns | string |
tagVersion($message, $where, $inc, $default)
Repository.php:768Tag 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.
| returns | static |
__construct($filename, $status, $origin)
Repository.php:51Inherited members (44)
| Constants | Declared by | 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 |
| Methods | Declared by | 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. |